Struts2配置文件通配符的使用
2013-06-24 17:04
447 查看
Struts2配置文件中使用通配符收藏
形式一:调用相同Action中的不同方法<action name="*Action" method="{1}" class="com.system.web.action.LoginAction"> <result name="input">/login.jsp</result> <result name="success">/welcom.jsp</result> <result name="error">/error.jsp</result> </action>
其中表达式{1}的值为name属性值中第一个*的值
如果用户请求的URL为loginAction.action,则调用com.system.web.action.LoginAction中的login方法
如果用户请求的URL为registerAction.action,则调用com.system.web.action.LoginAction中的register方法
形式二:调用不同Action中的execute方法
<action name="*Action" class="com.system.web.action.{1}Action"> <result name="input">/login.jsp</result> <result name="success">/welcom.jsp</result> <result name="error">/error.jsp</result> </action>
上面没有出现method属性,故默认调用对应action的execute方法
如果用户请求的URL为LoginAction.action,则调用com.system.web.action.LoginAction中的execute方法
如果用户请求的URL为RegisterAction.action,则调用com.system.web.action.RegisterAction中的execute方法
形式三:动态结果
<action name="FlowMonitor_*" method="{1}" class="com.monitor.web.action.FlowMonitorAction"> <result name="init">/pages/monitor/flowMonitor.jsp</result> <result name="table">/pages/monitor/flowMonitorBigTable.jsp</result> <result>/{1}.jsp</result> </action>
当处理结果是init时,会转到/pages/monitor/flowMonitor.jsp
当处理结果是success时,如果FlowMonitor_Query.action,则会执行FlowMonitorAction中的Query方法,并且跳转到/Query.jsp页面;
如果FlowMonitor_delete.action,则会执行FlowMonitorAction中的delete方法,并且跳转到/delete.jsp页面
相关文章推荐
- Struts2配置文件中使用通配符收藏method="{1}"
- 使用通配符完成struts2和spring多配置文件_悄悄俏俏
- Struts2 spring 多配置文件使用通配符
- Struts2 spring 多配置文件使用通配符
- Struts2配置文件中使用通配符
- Struts2使用通配符加载配置文件和通配符方法的底层实现学习
- struts2--配置文件通配符的使用
- struts2-配置文件中通配符的使用
- Struts2配置文件中使用通配符
- Struts2配置文件中的通配符的使用
- Struts2为应用指定多个配置文件和动态方法调用以及通配符的使用方法
- struts2--配置文件中使用通配符
- struts2 学习总结(上传文件,解决乱码,通配符的使用,整合fck)
- Struts2的struts.xml中配置及通配符的使用
- struts2的使用技巧:struts.xml配置文件的编辑
- 【Struts2学习笔记】struts2.5使用通配符配置action跳转
- Struts2国际化、拦截器配置以及使用struts上传文件
- Struts2系列:(4)使用多个struts配置文件
- structs学习(一):使用通配符配置文件
- Struts2-Action接受参数方式、method属性使用及通配符的配置