struts2常见报错
生活随笔
收集整理的這篇文章主要介紹了
struts2常见报错
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?Struts的版本是2.06,總結一下項目使用中碰到的問題,以備查用。這些錯誤大多數是人為的。
1、No result defined for action ***Action and result success??? 這個錯誤產生的原因是,在struts.xml中配置沒有配置success result。我的理解是action執行完后,必須產生一個result類。這個類可是servlet或是其他,但不能為空。
??? 解決方法:增加result success定義。
??? <result>***.jsp</result>
??
?? 2、No result defined for action ***Action?and result input
?? 這個錯誤,在提交數據時經常碰到。定義的struts2 intercept發揮了作用,當POJO類型與輸入的類型不同時,intercept類會中止攔截,并返回輸入頁面。詳細的錯誤可在使用<s:fielderror/>來獲取。
??? 解決方法:增加resut input定義。
??? <result name="input">***.jsp</result>
??
?? 3、There is no Action mapped for namespace / and action name ***Action
??? 可以直譯為沒有找到這個action,也就是說在struts.xml中沒有定義這個action。這個錯誤一般是action的名字拼寫錯誤造成的,請仔細檢查struts.xml的定義與頁面的acrion是否一致。
?? 4、Class ognl.OgnlRuntime can not access a member of class ***Action with modifiers "private"
??? 關鍵字是"private",action類中的字段為private,這樣頁面(如jsp)是無法訪問到的,這也是struts2面向對象的一大特征。
??? 解決方法:
??? 在action中添加set get方法,這樣struts會自訪問這個方法。set get方法必須遵循bean的標準寫法。
? 5、Exception starting filter struts2 未定變義struts-default。也package中加入extends="struts-default"
轉載于:https://blog.51cto.com/johnfong/935718
總結
以上是生活随笔為你收集整理的struts2常见报错的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 我在OSC的第一篇博文
- 下一篇: Android 关机弹出菜单