<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    探索與發現

    研究java技術

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      83 隨筆 :: 0 文章 :: 109 評論 :: 0 Trackbacks
    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>


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


    網站導航:
    博客園   IT新聞   Chat2DB   C++博客   博問  
     
    主站蜘蛛池模板: 99久久婷婷免费国产综合精品| 小说区亚洲自拍另类| 久久国产亚洲电影天堂| 亚洲va无码专区国产乱码| 亚洲字幕AV一区二区三区四区| 色偷偷亚洲男人天堂| 全部免费国产潢色一级| 在线精品亚洲一区二区小说| 亚洲男人的天堂在线播放| 亚洲色欲色欲www在线播放| 免费看香港一级毛片| 亚洲午夜国产精品无码老牛影视| 亚洲欧洲久久精品| CAOPORM国产精品视频免费| 2021在线观看视频精品免费| 全部免费国产潢色一级| 国产精品高清免费网站| 国产aⅴ无码专区亚洲av| 成人在线免费视频| 国产高清免费视频| 亚洲色无码一区二区三区| 久久永久免费人妻精品| 国产老女人精品免费视频| 亚洲春色另类小说| 一个人免费观看www视频在线| 最新亚洲成av人免费看| 欧洲精品99毛片免费高清观看| 亚洲人成网站色在线入口| 国产亚洲精品a在线观看app| 亚洲AV无码专区国产乱码不卡| 亚洲免费在线视频观看| 亚洲午夜精品一区二区| 成人毛片18女人毛片免费96| 亚洲中文无码a∨在线观看| 美女被爆羞羞网站免费| 成年性生交大片免费看| 一级一级一片免费高清| 亚洲午夜精品第一区二区8050| 99久热只有精品视频免费看 | 亚洲伊人精品综合在合线| 免费一级做a爰片性色毛片|