动态方法调用和使用通配符定义
由请求参数指定调用action中的方法
struts1中采用 dispatchAction的方式
<aciton path="control/action" type="...dispatchAction" parameter="method"/>
/control/action?method=aaa
■ struts2中的两种方式
法1.动态方法调用
package struts2.demo.action;
public class DyAction{
private String msg;
public String add(){
this.setMsg("Add");
return "success";
}
public String list_del(){
this.setMsg("delete");
return "success";
}
public String execute(){
this.setMsg("execute");
return "success";
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getMsg() {
return msg;
}
}
<action name="dy" class="struts2.demo.action.DyAction">
<result>/WEB-INF/page/dy.jsp</result>
</action>
调用时 采用 http://127.0.0.1:8080/demo/dy!add
可以采用<constant name="struts.enable.DynamicMethodInvocation" value="false"/>禁用动态方法调用
法2.使用通配符调用
<action name="dy_*" class="struts2.demo.action.DyAction" method="{1}">
<result>/WEB-INF/page/dy.jsp</result>
</action>
*通配符可以使用多个 {n}(n=第几个*)
这样可以通过http://127.0.0.1:8080/demo/dy_add来调用add方法 通配符可以使用在 class 或者<result>中....
分享到:
相关推荐
struts2-core-2.0.1.jar, struts2-core-2.0.11.1.jar, struts2-core-2.0.11.2.jar, struts2-core-2.0.11.jar, struts2-core-2.0.12.jar, struts2-core-2.0.14.jar, struts2-core-2.0.5.jar, struts2-core-2.0.6.jar,...
struts.xml文件中新增以下内容: <!-- 为修复struts2 s2-016、s2-017漏洞,重写DefaultActionMapper --> <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="myDefaultActionMapper" class=...
Struts框架中struts-config.xml文件配置小结
struts-core-1.3.10.jar, struts2-cdi-plugin-2.3.30.jar, struts2-codebehind-plugin-2.3.30.jar, struts2-config-browser-plugin-2.3.30.jar, struts2-convention-plugin-2.3.30.jar, struts2-core-2.3.30.jar, ...
struts-taglib-1.3.8.jar struts-taglib-1.3.8.jar
struts2-config-browser-plugin-2.3.24.jar, struts2-core-2.3.24.jar, struts2-jasperreports-plugin-2.3.24.jar, struts2-jfreechart-plugin-2.3.24.jar, struts2-pell-multipart-plugin-2.3.24.jar, struts2-...
赠送Maven依赖信息文件:struts2-json-plugin-2.3.24.pom; 包含翻译后的API文档:struts2-json-plugin-2.3.24-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.apache.struts:struts2-json-plugin:2.3.24; ...
struts-2.3.4-all.zip 笔记
struts2-ssl-plugin-1.2.1.jar
struts-config.xml struts标准配置文件 struts-config
struts2-bean-validation-plugin-2.5.2.jar, struts2-cdi-plugin-2.5.2.jar, struts2-config-browser-plugin-2.5.2.jar, struts2-convention-plugin-2.5.2.jar, struts2-core-2.5.2.jar, struts2-dwr-plugin-2.5.2....
struts2-convention-plugin-2.3.32
配置struts2 - 风轻云淡 配置struts2 - 风轻云淡
struts1.38包,struts-core-1.3.8.jarstruts1.38包,struts-core-1.3.8.jar
2018-08-24: 增加S2-057 Struts 2.3 to 2.3.34,Struts 2.5 to 2.5.16 此漏洞影响范围非常小,要求配置条件比较苛刻,同时,一些特定版本没有看到有沙盒绕过,所以,目前exp只是基于S2-045改写的,所以exp并不是...
jquery和struts2结合使用的jar包
struts2-convention-plugin-2.3.15.1.jar
struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置...
struts2--json包
struts-2.5.14-最核心的文件jar们,myeclipse struts2环境配置