探索與發現

          研究java技術

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            83 隨筆 :: 0 文章 :: 109 評論 :: 0 Trackbacks
          <2006年8月>
          303112345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          公告

          歡迎來到我的博客, email:xiaosazhai@gmail.com

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          文章分類

          相冊

          After effects

          Blogger's

          BT

          Flex

          Photoshop

          Photoshop 素材

          學習站點

          學習論壇

          影視制作

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          webwork使用 validation驗證框架,其采用的是攔截器
          看一個例子:
          ??? public String doExecute() throws Exception {
          ???return SUCCESS;
          ??? }
          }
          ------
          在xwork.xml里面添加
          <interceptors>
          ?<interceptor name="validator" class="com.opensymphony.xwork.validator.ValidationInterceptor"/>
          ?</interceptors>
          <action name="validation" class="helloWorld.SimpleAction">
          ???<result name="success" type="dispatcher">
          ????<param name="location">/simple_result.jsp</param>
          ???</result>
          ???<result name="error" type="dispatcher">
          ????<param name="location">/simple.jsp</param>
          ???</result>
          ???<!-- If you don't override execute(), you must do this: -->
          ???<result name="input" type="dispatcher">
          ????<param name="location">/simple.jsp</param>
          ???</result>
          ???<interceptor-ref name="validator" />
          ???<interceptor-ref name="debugStack" />
          ???<interceptor-ref name="defaultStack" />
          ???
          ??</action>
          注意interceptor為多個時與servlet里面的filter一樣按順序依次傳遞,假若失敗就為影響后面的程序運行效果.
          還有兩個jsp頁面
          simple_result.jsp
          <%@ taglib prefix="ww" uri="webwork"%>
          <html>
          ?<head>
          ??<title>WebWork Validation Example</title>
          ?</head>
          ?<body>
          ??<p>
          ???The count is
          ???<ww:property value="count" />
          ??</p>
          ??</form>
          ?</body>
          </html>
          --
          simple.jsp
          <%@ taglib prefix="ui" uri="webwork" %>
          <html>
          <head>
          ??? <title>WebWork Validation Example</title>
          </head>
          <body>
          <form action="validation.action" method="post">
          <table>
          ???? <ui:textfield label="Set the counter" name="count"/>
          ??? <ui:submit value="'Submit'"/>
          </table>
          </form>
          </body>
          </html>
          運行效果如下
          count must be between 0 and 5, current value is 8.

          下面為日期類型的驗證
          <field-validator type="date">
          <param name="min">12/22/2002</param>
          ? <param name="max">12/25/2002</param>
          ? <message>The date must be between 12-22-2002 and 12-25-2002.</message>
          </field-validator>
          </field>
          <field name="foo">
          <field-validator type="int">
          <param name="min">0</param>
          <param name="max">100</param>
          <message key="foo.range">Could not find foo.range!</message>
          </field-validator>
          </field>
          </validators>


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 丹寨县| 顺昌县| 定远县| 镇平县| 胶州市| 陈巴尔虎旗| 岑溪市| 孟连| 泰州市| 宝丰县| 防城港市| 苏尼特左旗| 开化县| 瑞安市| 静安区| 新闻| 宜兰县| 晋宁县| 华池县| 岗巴县| 施甸县| 龙门县| 天镇县| 太白县| 海阳市| 苗栗县| 南昌市| 桐梓县| 敖汉旗| 沙坪坝区| 横峰县| 渝中区| 龙井市| 惠水县| 贡嘎县| 定兴县| 奉新县| 沁阳市| 剑阁县| 青川县| 道孚县|