zoukankan      html  css  js  c++  java
  • 【J2EE】Struts2.5.10 无法进入Action类的指定方法

    Struts2.5.10 版本为了安全考虑 默认是不允许DMI(动态方法访问)的

      解决办法:

        step1.

          struts 标签下添加 <constant name="struts.enable.DynamicMethodInvocation" value="true"/>   //允许DML

        step2.  

          //以下四种选择根据需要选择

          <a> action 标签下添加 <allowed-methods>regex:.*</allowed-methods>     //允许DML指定action类方法

          <b> package标签下添加  action <allowed-methods>regex:.*</allowed-methods>    //允许DML所有action类方法:

          <c> 如果想要设置指定方法

              1. 给package标签设置 strict-method-invocation="true"

              2.action 标签下添加 <allowed-methods>方法名</allowed-methods>     //允许DML指定方法

          <d> 设置action标签的method属性(默认为execute)

     另外:

      *如果向再配置文件中使用通配符访问,则需给package标签添加strict-method-invocation="false"

     demo 如下

    -------------------------------------------------------------------------------------------------------------------

    <?xml version="1.0" encoding="UTF-8" ?>

    <!DOCTYPE struts PUBLIC     "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"     "http://struts.apache.org/dtds/struts-2.5.dtd">

    <!-- START SNIPPET: xworkSample -->

    <struts>    

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

       <package name="struts2" extends="struts-default">    

         <global-allowed-methods>regex:.*</global-allowed-methods>    

         <action name="act1" class="Action.Act1">         

           <result name="page2">/page2.jsp</result>       

           <!--<allowed-methods>regex:.*</allowed-methods> -->          

          </action>         

       </package>

    </struts>

  • 相关阅读:
    Angular项目在npm install之后用ng serve启动发生错误
    (TODO)Angular的通道
    使用React+redux+Node.js+MongoDB开发(二)--使用redux
    Angular中使用DomSanitizer防范跨站脚本攻击类(XSS)的安全问题
    使用React+redux+Node.js+MongoDB开发(一)
    数组的数字和非数字下标的区别
    echarts绘制饼图时的一点特殊设置
    Angular项目中迭代生成的树,激活选中的节点,并将节点数据发送到父节点
    Ubuntu 设定壁纸自动切换的shell脚本
    Navicat for mysql linux 破解方法
  • 原文地址:https://www.cnblogs.com/LightChan/p/7139815.html
Copyright © 2011-2022 走看看