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>

  • 相关阅读:
    为什么页面设计宽度要控制在960px
    RRDtool运用
    cacti监控jvm
    cacti安装
    rConfig v3.9.2 授权认证与未授权RCE (CVE-2019-16663) 、(CVE-2019-16662)
    Linux安全学习
    Github-Dorks与辅助工具
    警方破获超大DDoS黑产案,20万个僵尸网络运营商被抓
    SRC漏洞挖掘
    威胁情报木马病毒样本搜集
  • 原文地址:https://www.cnblogs.com/LightChan/p/7139815.html
Copyright © 2011-2022 走看看