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

<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>

struts2 DMI的更多相关文章

  1. Struts2 DMI的使用

    Struts2的Action类中可以放置多个方法并在struts.xml中配置供页面调用.只要方法符合execute()方法的标准即返回类型是String就可以了. 同一个Action多个方法调用的方 ...

  2. struts2 DMI问题

    最新开始学习struts2,在官网上下载的最新的struts2(2.3.15.2), jar包,在使用动态方法调用的时候老是报错,错误代码如下HTTP Status 404 - There is no ...

  3. struts2 s2-032漏洞分析

    0x01Brief Description 最近面试几家公司,很多都问到了s2漏洞的原理,之前调试分析过java反序列化的漏洞,觉得s2漏洞应该不会太难,今天就分析了一下,然后发现其实漏洞的原理不难, ...

  4. ref:Struts2 命令执行系列回顾

    ref:http://www.zerokeeper.com/vul-analysis/struts2-command-execution-series-review.html Struts2 命令执行 ...

  5. struts2 CVE-2012-0392 S2-008 Strict DMI does not work correctly allows remote command execution and arbitrary file overwrite

    catalog . Description . Effected Scope . Exploit Analysis . Principle Of Vulnerability . Patch Fix 1 ...

  6. Struts2的DMI跟SMI

    我使用的Struts2的版本是2.5.2,今天在使用Struts2的DMI(动态方法调用)的时候出现了一个有趣的问题,我先把我的配置及代码展示一下: web.xml <filter> &l ...

  7. struts2的动态方法调用(DMI)和通配符映射

    动态方法调用   1.Struts2默认关闭DMI功能,需要使用需要手动打开,配置常量 struts.enable.DynamicMethodInvocation = true 2.使用“!”方法,即 ...

  8. struts2 中使用DMI(动态调用方法)方式配置action

    1.使用 "!"方式,即 action名称 ! 方法名称 struts.xml 配置 <package name="user" namespace=&qu ...

  9. Struts2动态方法调用(DMI)

    当structs.xml解析到Action的时候,默认执行的是此action的execute()方法,但是实际开发中,我们的action中含有很多方法,比如说增删改查的方法,那么structs.xml ...

随机推荐

  1. Javascript之旅——第八站:说说instanceof踩了一个坑

    前些天写js遇到了一个instanceof的坑,我们的页面中有一个iframe,我在index页面中计算得到了一个array,然后需要传递到Flight页面 这个嵌套的iframe中的一个函数(Sea ...

  2. Oracle 列转行函数 Listagg()

    这是最基础的用法: LISTAGG(XXX,XXX) WITHIN GROUP( ORDER BY XXX) 例: select listagg(oeid,',') within GROUP (ord ...

  3. 0014 Java学习笔记-集合-HashMap集合

    主要的方法 + 构造方法: * HashMap(); - 默认大小16,负载因子0.75 * HashMap(int initialCapacity); * HashMap(int initialCa ...

  4. Windows搭建python开发环境,python入门到精通[一]

    从大学开始玩python到现在参加工作,已经有5年了,现在的公司是一家.net的公司用到python的比较少,最近公司有新项目需要用到python,领导希望我来跟其他同事training,就有了这篇博 ...

  5. 多年前写的DataTable与实体类的转换,已放github

    本文版权归mephisto和博客园共有,欢迎转载,但须保留此段声明,并给出原文链接,谢谢合作. 文章是哥(mephisto)写的,SourceLink 阅读目录 介绍 起因 代码 UnitTest G ...

  6. MySQL运行状态show status中文详解(转)

    要查看MySQL运行状态,要优化MySQL运行效率都少不了要运行show status查看各种状态,下面是参考官方文档及网上资料整理出来的中文详细解释: 状态名 作用域 详细解释 Aborted_cl ...

  7. arcgis 随手记

    1,ArcGISDynamicMapServiceLayer   3.0  用  4.1 以后用MapImageLayer 代码如下: <!DOCTYPE html> <html&g ...

  8. ubuntu16.04源码编译安装wine1.8.6安装不上引来的错误

    configure: libxcomposite 64-bit development files not found, Xcomposite won't be supported. configur ...

  9. C++杂谈(二)初识vector容器与迭代器

    教科书中失踪的vector 很奇怪的一件事情,在当时学习C++的时候,老师并没有讲授容器的内容,当时参考的谭浩强老师的红皮C++也没有这个内容,不知为何.后来再学C++,发现容器是一个很重要的概念,在 ...

  10. eclipse 提示错误**cannot be resolved to a type

    这是某个对象不能识别为类型,比如你写了个类,名字叫Hello,如果你调用它的时候不小心写成hello,或者helo,那么就会报这样的错误,很容易改正的,只要你细心一点