struts2_7_Action类中方法的动态调用
2018-01-23 10:54
344 查看
(一)直接调用方法(不推荐使用)
1)Action类:
2)struts.xml文件的配置:
当输入:http://localhost:8080/Struts_3/test/emp.action
时会输出:execute 即调用execute()方法;
当输入:http://localhost:8080/Struts_3/test/emp!other.action
时会输出:other 即调用other()方法。
(二)使用通配符(推荐使用)
1)Aciton类与(一)中的同样
2)struts.xml文件的配置:
訪问路径:http://localhost:8080/Struts_3/test/empexecute
这时会输出:execute 即调用execute()方法;
訪问路径:http://localhost:8080/Struts_3/test/empother
这时会输出:other 即调用other()方法。
1)Action类:
private String savePath; public String getSavePath() { return savePath; } public void setSavePath(String savePath) { this.savePath = savePath; } public String other() { savePath = "other"; return "success"; } public String execute() { savePath = "execute"; return "success"; }
2)struts.xml文件的配置:
<struts> <package name="package" namespace="/test" extends="struts-default"> <action name="emp" class="struts.employeeAction" method="execute"> <result name="success">/index.jsp</result> </action> </package> </struts>
当输入:http://localhost:8080/Struts_3/test/emp.action
时会输出:execute 即调用execute()方法;
当输入:http://localhost:8080/Struts_3/test/emp!other.action
时会输出:other 即调用other()方法。
(二)使用通配符(推荐使用)
1)Aciton类与(一)中的同样
2)struts.xml文件的配置:
<struts> <package name="package" namespace="/test" extends="struts-default"> <action name="emp*" class="struts.employeeAction" method="{1}"> <result name="success">/index.jsp</result> </action> </package> </struts>
訪问路径:http://localhost:8080/Struts_3/test/empexecute
这时会输出:execute 即调用execute()方法;
訪问路径:http://localhost:8080/Struts_3/test/empother
这时会输出:other 即调用other()方法。
相关文章推荐
- Struts2中Action的动态方法调用
- struts2教程:10、动态方法调用和使用通配符定义action
- Struts2动态方法调用和使用通配符定义action
- Struts2学习---基本配置,action,动态方法调用,action接收参数
- struts2中使用DMI(动态调用方法)方式配置action
- Struts2基础之四:动态方法调用(DMI)和action通配符
- Struts2关于Action的系统训练4关于动态方法调用DMI
- Struts2 Action中动态方法调用、通配符的使用
- struts2_7_Action类中方法的动态调用
- 使用<a>标签调用struts2的action、传递动态参数、以及参数中出现加号等特殊字符的处理方法
- struts2中动态方法调用和使用通配符定义Action
- struts2动态方法调用 ActionName!methodName.action
- struts2学习 - action -3 动态方法调用 DMI
- struts2拦截器的方法过滤功能在Action动态方法调用中的应用 .
- Struts2的动态调用action方法
- struts2中动态方法调用和使用通配符定义Action
- 第三章Struts2 Action中动态方法调用、通配符的使用
- Struts2中Action的动态调用方法
- 关于Struts2使用Action的动态方法调用
- struts2 DMI用感叹号动态调用方法时提示there is no action mapped for