struts2动态方法调用
来源:互联网 发布:产后如何收缩骨盆 知乎 编辑:程序博客网 时间:2024/06/14 18:14
如果Action中存在多个方法时,我们可以使用!+方法名调用指定方法。如下:
public class HelloWorldAction{ private String message; .... public String execute() throws Exception{ this.message = "我的第一个struts2应用"; return "success"; } public String other() throws Exception{ this.message = "第二个方法"; return "success"; }}
假设访问上面action的URL路径为: /struts/test/helloworld.action
要访问action的other() 方法,我们可以这样调用:
/struts/test/helloworld!other.action
如果不想使用动态方法调用,我们可以通过常量struts.enable.DynamicMethodInvocation关闭动态方法调用。
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<package name="itcast" namespace="/test" extends="struts-default"> <action name="helloworld_*" class="cn.itcast.action.HelloWorldAction" method="{1}"> <result name="success">/WEB-INF/page/hello.jsp</result> </action></package>public class HelloWorldAction{ private String message; .... public String execute() throws Exception{ this.message = "我的第一个struts2应用"; return "success"; } public String other() throws Exception{ this.message = "第二个方法"; return "success"; }}
要访问other()方法,可以通过这样的URL访问:/test/helloworld_other.action
method=”{1}”中的{1}指获取通配符第一个字符,“{1}”同样也可用于class=“”和result路径中
0 0
- struts2动态方法调用
- Struts2 动态方法调用
- struts2动态方法调用
- struts2 动态方法调用
- Struts2动态方法调用
- struts2--动态方法调用
- Struts2动态方法调用
- Struts2动态方法调用
- Struts2动态方法调用
- struts2 动态方法调用
- struts2动态方法调用
- struts2,动态方法调用
- Struts2动态方法调用
- Struts2动态方法调用
- Struts2动态方法调用
- struts2动态方法调用
- Struts2动态方法调用
- struts2动态方法调用
- JS基础——自定义属性的应用1
- 微信公众平台开发(一) 配置接口
- JS基础——自动生成一组新闻
- IOS开发之UIView
- [leetcode]Implement strStr()
- struts2动态方法调用
- 室内团队游戏
- jquery学习笔记(转)
- 我是菜鸡:java Runtime类学习
- poj 2250 Compromise 【最长公共子序列变形】
- Fiddler 教程
- C中的volatile用法
- jquery的全选代码
- CUDA函数前缀与存储器前缀讨论