标签:style class blog code java http
在使用DMI(动态方法调用)的时候要注意struts.xml配置时要把
1 |
<constant name= "struts.enable.DynamicMethodInvocation"
value= "true" /> |
不然会出现错误
完整示例代码
struts.xml
<constant name="struts.devMode" value="true" /> <constant name="struts.enable.DynamicMethodInvocation" value="true"/> <package name="default" namespace="/path" extends="struts-default"> <action name="path" class="com.pengli.structs2.actionstudy.IndexAction3"> <result name ="a"> /MyPath.jsp </result> </action> </package> <package name="default2" namespace="/" extends="struts-default"> <action name="path2" class="com.pengli.structs2.actionstudy.IndexAction3"> <result name ="a"> /MyPath.jsp </result> <result name ="add"> /hello.jsp </result> <result name ="edit"> /index.jsp </result> </action> </package>
IndexAction3
package com.pengli.structs2.actionstudy; import com.opensymphony.xwork2.ActionSupport; public class IndexAction3 extends ActionSupport{ @Override public String execute() throws Exception { // TODO Auto-generated method stub return "a"; } public String add() { return "add"; } public String edit() { return "edit"; } }
web.xml
<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
标签:style class blog code java http
原文地址:http://www.cnblogs.com/li-peng/p/3782395.html