記錄一次錯誤——關於Struts2的package使用

在一個demo中,我把struts.xml分成每個包下一個(分爲struts1.xml、struts2.xml、struts3.xml),然後用struts.xml把這些分文件include起來。在每次寫的時候,都是直接複製粘貼然後修改。

當使用struts3.xml時,出現問題了,無法找到我配置的action。查原因,也是運氣好,亂試了幾下就被我碰到了。

原來我忘記修改package標籤中的name屬性了。在聽課的時候老師說這個那麼隨意起什麼,所以修改時就沒有注意他,導致struts1.xml和struts3.xml中的package的name屬性都爲demo1。這就導致了無法找到struts3.xml配置的action(struts1.xml配置的action仍然可以找到)。

錯誤提示爲:

HTTP Status 404 – Not Found


Type Status Report

Message There is no Action mapped for namespace [/] and action name [requestDemo1] associated with context path [/struts2].

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/7.0.94

 

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