struts2.5.12版本使用action通配符提示找不到action的問題

我配置了一個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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章