struts2.xml配置要点(验证基于方法级)
- <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
- <struts>
- <include file="struts-default.xml" />
- <!--前几天有人说继承不成功,有贴回复是<package>和<include>顺序问题(<include/>和<package>没先后顺序),关键在于解析是自上而下的,要继承某xml文件,就要先引入该文件-->
- <package name="default" extends="struts-default">
- <!--定义默认视图,我定义默认为freemarker-->
- <result-types>
- <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult" default="true" />
- </result-types>
- <!--如果你仅仅需要页面跳转,就没必要在写一个action了,直接用ActionSupport就行了-->
- <action name="login" class="com.opensymphony.xwork2.ActionSupport">
- <!--默认返回success,我上面定义默认type为freemarker,这里就不用定义type属性了-->
- <result>/Login.ftl</result>
- </action>
- <action name="userInput" class="pro.action.app.UserRegisterAction">
- <interceptor-ref name="createSession">
- <!--经测试,该拦截器没有该参数,设置后会抛异常;该参数主要设置该拦截器作用于那些方法-->
- <!--<param name="includeMethods">input,back,cancel</param>-->
- </interceptor-ref>
- <interceptor-ref name="token">
- <param name="excludeMethods">input,back,cancel</param>
- </interceptor-ref>
- <interceptor-ref name="model-driven" />
- <interceptor-ref name="validationWorkflowStack">
- <!--设置不需拦截的方法-->
- <param name="validation.excludeMethods">input,back,cancel</param>
- <param name="workflow.excludeMethods">input,back,cancel</param>
- </interceptor-ref>
- <result name="invalid.token">/doubleSubmit.html</result>
- <result name="input">/app/UserRegister.ftl</result>
- <result name="login">/Login.ftl</result>
- <result name="success">/Login.ftl</result>
- </action>
- <!--注意你也可以给action设置参数,同样是用<param/>赋值-->
- </package>
- <include file="cfg/struts/struts-filedownload.xml"></include>
- </struts>
相关推荐
FrederickBala 2020-02-22
unit00 2020-02-21
FrederickBala 2020-01-31
neweastsun 2019-11-26
zuncle 2019-11-25
songxiugongwang 2019-10-31
苗疆三刀的随手记 2019-04-23
royrui 2012-08-20
qinbiao00 2015-06-17
heshizui 2012-11-16
fish 2013-06-26
开心就好 2012-02-21
markzl 2010-05-26
F1 显示当前程序或者windows的帮助内容。F2 当你选中一个文件的话,这意味着“重命名”。F10或ALT 激活当前程序的菜单栏。windows键或CTRL+ESC 打开开始菜单。CTRL+ALT
WuTongCLKIP 2009-06-11
Cocotwp 2019-07-04
huangsusan 2019-07-01
youandme 2019-07-01
88570299 2019-07-01