来看一个例子,例如有一个CrudAction, 其中有两个方法,input 和 delete,我们定义两个action:Crud_input和Crud_delete。我们可以在struts.xml中配置如下:
xml 代码
- <action name="Crud_*" class="example.Crud" method="{1}">
这样,当struts2遇到Crud_input时,就会自动去找Crud的input方法,当遇到Crud_delete时,就会自动去找Crud的delete方法。
见另一个例子:
xml 代码
- <action name="*Crud" class="example.Crud" method="{1}">
这里,当struts2解析到editCrud时,就会自动去找Crud的edit方法。
按我的理解,method="{1}"的意思就是告诉struts2去找前面*中出现的方法并执行。
又如:
xml 代码
- <action
- name="/edit*"
- class="org.apache.struts.webapp.example.Edit{1}Action">
- <result
- name="failure"
- path="/mainMenu.jsp"/>
- <result
- path="/{1}.jsp"/>
- </action>
分享到:
相关推荐
Hibernate3.3.1+Spring2.5.5+Struts2 2.0.1.2例子 Struts2使用了通配符的配置方式进行配置!
struts2演示 <br>1./helloworld - helloworld 2./spring - 与spring整合 3./coc - 惯例优先配置,零配置文件 - codebehind不支持redirect,chain等操作,需要自己写jsp跳转 4./crud - CRUD,Create Read...
《JavaServer Faces 2.0完全参考手册》针对javaserver faces(jsf)2.0中的变化进行了全面的修订与更新,涵盖了javeee的官方标准web开发架构的每个方面。在这本权威著作中,sun microsystems公司中的jsf合作规范领导者...
《JavaServer Faces 2.0完全参考手册》针对javaserver faces(jsf)2.0中的变化进行了全面的修订与更新,涵盖了javeee的官方标准web开发架构的每个方面。在这本权威著作中,sun microsystems公司中的jsf合作规范领导者...
4.7.2. Application context构造器中资源路径的通配符 4.7.3. FileSystemResource 提示 5. 校验,数据绑定,BeanWrapper,与属性编辑器 5.1. 简介 5.2. 使用Spring的Validator接口进行校验 5.3. 从错误代码到...
Struts2框架介绍、工作原理与架构分析、6大配置文件分析使用通配符定义action、动态方法调用,ActionContext及ServletActionContext使用,模型驱动、属性驱动,默认转换器的介绍,中的表单校验,中的国际化,文件...
118 8.3.5 Struts2配置文件 119 8.4 Action的配置方式 121 8.4.1 动态方法调用 121 8.4.2 设置action元素的method属性 122 8.4.3 使用通配符配置action 122 8.4.4 默认action 123 8.5 拦截器Interceptor 123 8.5.1 ...
4.7.2. Application context构造器中资源路径的通配符 4.7.2.1. Ant风格的pattern 4.7.2.2. classpath*: 前缀 4.7.2.3. 其他关于通配符的说明 4.7.3. FileSystemResource 提示 5. 校验,数据绑定,BeanWrapper,与...
4.7.2. Application context构造器中资源路径的通配符 4.7.3. FileSystemResource 说明 5. 校验,数据绑定,BeanWrapper,与属性编辑器 5.1. 简介 5.2. 使用Spring的Validator接口进行校验 5.3. 从错误代码到...
4.7.2. Application context构造器中资源路径的通配符 4.7.3. FileSystemResource 提示 5. 校验,数据绑定,BeanWrapper,与属性编辑器 5.1. 简介 5.2. 使用Spring的Validator接口进行校验 5.3. 从错误代码到...
4.7.2. Application context构造器中资源路径的通配符 4.7.3. FileSystemResource 说明 5. 校验,数据绑定,BeanWrapper,与属性编辑器 5.1. 简介 5.2. 使用Spring的Validator接口进行校验 5.3. 从错误代码到...