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>

  • 相关阅读:
    自然语言处理1-1 算法时间复杂度
    tensorflow2.0(1):简介
    基于PKCS#11的应用架构
    数字证书应用改造需求调研-2015-10-19
    签名验证工具Aloaha Sign
    PDF签名应用研究小结
    用bcp导sql server数据到excel文件
    无线网卡和有线网卡的嗅探模式的区别
    Tomcat6源代码在Eclipse里调试简要说明
    OpenLDAP 主从复制配置
  • 原文地址:https://www.cnblogs.com/LightChan/p/7139815.html
Copyright © 2011-2022 走看看