struts2的通配符 * 无法使用,method无效,无法访问404

在struts2 2.3版本以后为了增加安全性,在action中添加了对方法访问的权限,如果要使用通配符 * 调用方法的话,需要添加额外的代码,不然将会报无法访问的错误
在这里插入图片描述
有以下几种解决方法

  • 一.在action标签中添加< allowed-methods>标签

< allowed-methods>save< /allowed-methods>
< allowed-methods>方法1,方法2,…< /allowed-methods>
< allowed-methods >regex:*< /allowed-methods>

  • 二.在package 标签中添加 global-allowed-methods 标签

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

  • 三.在package 标签上添加strict-method-invocation 属性

strict-method-invocation=“false”





    
    
   
    
       
        
        
        save

    


你可能感兴趣的:(Java,struts2)