使用通配符定义Action
来源:互联网 发布:js中的eval方法 编辑:程序博客网 时间:2024/05/21 09:02
使用通配符定义Action
在开发中通常使用通配符的方法来定义Action,定义一个Action为HelloWorld的类,如:
package zjh.struts2.lx;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String execute() {
message = "这是第一个方法";
return SUCCESS;
}
public String other_method(){
message = "这是第二个方法";
return SUCCESS;
}
}
当Action定义好后,只需要在struts.xml配置文件中的action加个通配符(*)即可,如:
<package name="test" namespace="/test" extends="struts-default">
<action name="HelloWorld_*" class="zjh.struts2.lx.HelloWorld" method="{1}">
<result name="success">/success.jsp</result>
</action>
</package>
此时 ” HelloWorld_* ”表示的是匹配所有以“HelloWorld”开头的Action,而method中的{1}代表的是*的内容,即如果Action为“HelloWorld_other_method”则{1}代表的就是“other_method”。如果这时要访问Action中的other_method()方法,可以通过这样的URL访问:
http://localhost:8080/struts/test/HelloWorld_other_method.action
- 使用通配符定义Action
- 使用通配符定义Action
- Struts2 使用通配符定义action
- struts2 使用通配符动态定义action
- action动态方法调用和使用通配符定义action
- 通配符定义action
- struts2中动态方法调用和使用通配符定义Action
- struts2动态方法调用和使用通配符定义action
- 动态方法调用和使用通配符定义action
- struct2动态方法调用和使用通配符定义action
- Struts2动态方法调用和使用通配符定义action
- 八、动态方法的调用和使用通配符定义action
- Struts2_动态方法调用和使用通配符定义action
- struts2-10动态方法调用和使用通配符定义action
- 使用通配符配置 Action
- 使用通配符配置action
- Action使用通配符
- Action通配符使用
- struts2文件上传
- LeetCode Longest Substring Without Repeating Characters
- CSS实现背景透明,文字不透明(各浏览器兼容)
- C语言简单程序
- 基于hadoop0.20.2mapreducer的实例
- 使用通配符定义Action
- char *s 与char s[]的区别
- C++智能指针浅析
- 多线程 《多线程操作同一变量》
- 十、从头到尾彻底理解傅里叶变换算法、上
- Cocos2d-x处理双击事件的两种方法!
- RTSP服务器(一)
- Wikioi 1082线段树成段更新成段查询
- c语言----简单的c程序设计