struts 常見錯誤彙總

2021-08-24 21:08:35 字數 1426 閱讀 4788

1.no bean found under attribute key ***

在struts-config.xml裡定義了乙個actionform,但type屬性指定的類不存在,type屬性的值應該是form類的全名。或者是在action的定義中,name或attribute屬性指定的actionform不存在。

2.cannot find bean *** in any scope

在action裡一般會request.setattribute()一些物件,然後在轉向的jsp檔案裡(用tag或request.getattribute()方法)得到這些物件並顯示出來。這個異常是說jsp要得到乙個物件,但前面的action裡並沒有將物件設定到request(也可以是session、servletcontext)裡。

可能是名字錯了,請檢查jsp裡的tag的一般是name屬性,或getattribute()方法的引數值;或者是action邏輯有問題沒有執行setattribute()方法就先轉向了。

還有另外乙個可能,純粹是jsp檔案的問題,例如會指定乙個id值,然後在迴圈裡使用這個值作為name的值,如果這兩個值不同,也會出現此異常。(都是乙個道理,request裡沒有對應的物件。)

3.missing message for key "***"

4.no getter method for property *** of bean teacher

這條異常資訊說得很明白,jsp裡要取乙個bean的屬性出來,但這個bean並沒有這個屬性。你應該檢查jsp中某個標籤的property屬性的值。例如下面**中的cade應該改為code才對:

在.jsp的標籤裡指定action='/***',但這個action並未在struts-config.xml裡設定過。

forward的path屬性指向的jsp頁面不存在,請檢查路徑和模組,對於同一模組中的action轉向,path中不應包含模組名;模組間轉向,記住使用contextrelative="true"。

7.the element type "***" must be terminated by the matching end-tag "***".

這個是struts-config.xml檔案的格式錯誤,仔細檢查它是否是良構的xml檔案,關於xml檔案的格式這裡就不贅述了。

8.the reference to entity " " must end with the ';' delimiter.

這個錯誤是因為struts.xml中間出現了「&」。由於xml文字不支援「&」符號,如果需要使用的話就需要使用"&" 即可。

10.org.xml.sax.saxparseexception: invalid byte 2 of 2-byte utf-8 sequence

tomcat配置檔案context.xml中間有中文。

Struts常見錯誤的全面彙總

1 no bean found under attribute key 在struts config.xml裡定義了乙個actionform,但type屬性指定的類不存在,type屬性的值應該是form類的全名。或者是,在action的定義中,name或attribute屬性指定的actionfor...

C C 常見錯誤彙總

筆記本 macbook air,作業系統 macos,ide clion,工具鏈如下圖 出錯原因 片段沒有寫在函式中。解決方法 將 片段寫進函式中。出錯原因 main.cpp中沒有找到對應的函式名宣告,沒有在.cpp引用包含該函式名的標頭檔案.h。解決方法 引入對應標頭檔案。出錯原因 main.cp...

django 常見錯誤彙總

file d python django mysite mysite view.py line 7syntaxerror unicode error utf 8 codec can t decode byte 0xa3 in position 0 invalid start byte 1 synta...