我配置了一個PageAction
<action name="*" method="{1}" class="com.cheng.web.action.PageAction">
<result name="success">/page/{1}.jsp</result>
<allowed-methods>delete,update,insert,select</allowed-methods>
</action>
調用update,select,insert,delete方法,其中delete是可以返回正常頁面的,其他的都不能夠調用,報錯找不到對應的Action
原因是在struts2.3版本之後,使用通配符調用方法時,內部會驗證是否允許訪問該方法,所以要在Action中加上
<allowed-methods>delete,update,insert,select</allowed-methods>
那麼爲什麼delete方法可以正常調用呢,是因爲在struts2-core/struts-default.xml文件裏,默認配置了:
<global-allowed-methods>execute,input,back,cancel,browse,save,delete,list,index</global-allowed-methods>