創建Struts2 應用遇到的一些問題總結

訪問頁面時:
報錯1:
"The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."
原因是:
/hello.jsp
struts.xml中result標籤裏的name值跟對應…Action類的返回值不一致導致的.

報錯2:
給方法繼承 extends ActionSupport
然後引入 import com.opensymphony.xwork2.ActionSupport;
報錯 "The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .cl"
原因是我的項目運行的JDK是1.8的,將項目運行環境改成MyEclipse 10自帶的 JDK1.6 的就好了…

報錯3 :
(package,action標籤寫出來不展示,這裏用…替代)
"Package demo2 extends undefined package struts.default"
原因是:
<… name=“demo2” extends=“struts.default” namespace="/">
<… name=“form1” class=“cn.itcast.form.Form1DemoAction”></…>
</…>
應該是: struts-default

報錯4:
報404錯誤
報錯原因很可能就是,沒有配置struts2過濾器.
還有一種可能就是配置文件中對應文件名稱寫的不對.

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