码迷,mamicode.com
首页 > 其他好文 > 详细

struts2 DMI

时间:2014-06-12 10:34:24      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   java   http   

在使用DMI(动态方法调用)的时候要注意struts.xml配置时要把

1
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>

不然会出现错误

bubuko.com,布布扣

 

完整示例代码

struts.xml

bubuko.com,布布扣
 <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>
bubuko.com,布布扣

IndexAction3

bubuko.com,布布扣
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";
    }
}
bubuko.com,布布扣

web.xml

bubuko.com,布布扣
  <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>
bubuko.com,布布扣

 

 

 

struts2 DMI,布布扣,bubuko.com

struts2 DMI

标签:style   class   blog   code   java   http   

原文地址:http://www.cnblogs.com/li-peng/p/3782395.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!