Struts2.5 通配符不能使用問題

今天在上機時,登錄和註冊使用通配符在 Struts 2 的低版本好用,但是回到宿舍後使用最新的 2.5.10 版本就不可以用了。

 <action name="*Action" class="com.guofeng.action.UserAction" method="{1}">
        <result name="success">{1}_success.jsp</result>
        <result name="error">failed.jsp</result>
 </action>

按照下面寫法可以繼續使用:

<action name="*Action" class="com.guofeng.action.UserAction" method="{1}">
        <result name="success">{1}_success.jsp</result>
        <result name="error">failed.jsp</result>
        <allowed-methods>login,register</allowed-methods>
</action>

只需要加上 <allowed-methods>Action的方法名</allowed-methods> 這一句就可以了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章