Posted on 2006-04-01 12:11
天空蒼茫 閱讀(240)
評論(0) 編輯 收藏
異常
?
|
javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login
(
/Login
是你的
action
名字)
?
|
?
?
|
?
?
|
可能原因
?
|
action
沒有再
struts-config.xml
?
中定義,或沒有找到匹配的
action
,例如在
JSP
文件中使用
<html:form action="
Login.do
"
.
將表單提交給
Login.do
處理,如果出現(xiàn)上述異常,請查看
struts-config.xml
中的定義部分,有時可能是打錯了字符或者是某些不符合規(guī)則,可以使用
struts console
工具來檢查。
?
|
異常
?
|
org.apache.jasper.JasperException: Cannot retrieve definition for form bean null
?
|
可能原因
???????
?
??????
|
這個異常是因為
Struts
根據(jù)
struts-config.xml
中的
mapping
沒有找到
action
期望的
form bean
。大部分的情況可能是因為在
form-bean
中設置的
name
屬性和
action
中設置的
name
屬性不匹配所致。換句話說,
action
和
form
都應該各自有一個
name
屬性,并且要精確匹配,包括大小寫。這個錯誤當沒有
name
屬性和
action
關聯(lián)時也會發(fā)生,如果沒有在
action
中指定
name
屬性,那么就沒有
name
屬性和
action
相關聯(lián)。當然當
action
制作某些控制時,譬如根據(jù)參數(shù)值跳轉到相應的
jsp
頁面,而不是處理表單數(shù)據(jù),這是就不用
name
屬性,這也是
action
的使用方法之一。
?
|
異常
?
|
No action instance for path /xxxx could be created
?
|
可能原因
?
|
特別提示:因為有很多中情況會導致這個錯誤的發(fā)生,所以推薦大家調(diào)高你的
web
服務器的日志
/
調(diào)試級別,這樣可以從更多的信息中看到潛在的、在試圖創(chuàng)建
action
類時發(fā)生的錯誤,這個
action
類你已經(jīng)在
struts-config.xml
中設置了關聯(lián)(即添加了
<action>
標簽)。
?
|
在
struts-config.xml
中通過action標簽的class屬性指定的action類不能被找到有很多種原因,例如:
-
定位編譯后的
.class
文件失敗。
Failure to place compiled
.class
file for the action in the classpath (
在
web
開發(fā)中,
class
的的位置在
r
WEB-INF/classes,
所以你的action class必須要在這個目錄下。例如你的action類位于WEB-INF/classes/action/Login.class,那么在struts-config.xml中設置action的屬性type時就是action.Login
).
-
拼寫錯誤,這個也時有發(fā)生,并且不易找到,特別注意第一個字母的大小寫和包的名稱。
?
?
|
在
struts-config.xml中指定的action類沒有繼承自Stuts的Action類,或者你自定義的Action類沒有繼承自Struts提供的Action類。
你的action類必須繼承自Struts提供的Action類。
?
?
|
你的classpath的問題。例如web server沒有發(fā)現(xiàn)你的資源文件,資源文件必須在
WEB-INF/classes/目錄下
。
|
Problem in
struts-config.xml
file with action mapping.
|
Problem with
data-sources.xml
file.
?
|
異常
?
|
javax.servlet.jsp.JspException: No getter method for property username of bean org.apache.struts.taglib.html.BEAN
?
|
可能原因
?
|
沒有位
form bean
中的某個變量定義
getter
方法
|
這個錯誤主要發(fā)生在表單提交的
FormBean
中,用
struts
標記
<html:text property=”username”>
時,在
FormBean
中必須有一個
getUsername()
方法。注意字母“
U
”。
|
錯誤
?
|
java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm
?
|
可能原因
?
|
這個錯誤主要發(fā)生在在
classpath
中找不到相應的
Java .class
文件。如果這個錯誤發(fā)生在
web
應用程序的運行時,主要是因為指定的
class
文件不在
web server
的
classpath
中(
/WEB-INF/classes
?
和
/WEB-INF/lib)。
在上面的錯誤中,原因是找不到ActionForm類。
?
?
|
異常
?
|
javax.servlet.jsp.JspException: Exception creating bean of class org.apache.struts.action.ActionForm: {1}
?
|
可能原因
?
|
Instantiating Struts-provided
ActionForm
class directly instead of instantiating a class derived off
ActionForm
. This might occur implicitly if you specify that a form-bean is this Struts
ActionForm
class rather than specifying a child of this class for the form-bean.
?
|
Exception
?
|
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
?
|
可能原因
?
|
不是標識
Struts actionServlet
的
<servlet>
標記就是映射
.do
擴展名的
<sevlet-mapping>
標記或者兩者都沒有在
web.xml
中聲明。
?
|
在
struts-config.xml
中的打字或者拼寫錯誤也可導致這個異常的發(fā)生。例如缺少一個標記的關閉符號
/>
。最好使用
struts console
工具檢查一下
。
?
|
另外,
load-on-startup
必須在
web.xml
中聲明,這要么是一個空標記,要么指定一個數(shù)值,這個數(shù)值用來表
servlet
運行的優(yōu)先級,數(shù)值越大優(yōu)先級越低。
?
|
還有一個和使用
load-on-startup
有關的是使用
Struts
預編譯
JSP
文件時也可能導致這個異常。
?
|
異常
?
|
java.lang.NullPointerException at org.apache.struts.util.RequestUtils.forwardURL(RequestUtils.java:1223)
|
可能原因
?
|
在
struts-config.xml
中的
forward
元素缺少
path
屬性。例如應該是如下形式:
<forward name="userhome" path="/user/userhome.jsp"/>
|
Exception
?
|
javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
?
|
?
?
|
?
?
|
Probable Causes
?
|
試圖在Struts的form標記外使用form的子元素。這常常發(fā)生在你在</html:form>后面使用Struts的html標記。
另外要注意可能你不經(jīng)意使用的無主體的標記,如<html:form … />,這樣web 服務器解析時就當作一個無主體的標記,隨后使用的所有<html>標記都被認為是在這個標記之外的,如又使用了<html:text property=”id”>
還有就是在使用taglib引入HTML標記庫時,你使用的prefix的值不是html。?
|
Exception
?
|
javax.servlet.jsp.JspException: Missing message for key xx.xx.xx
?
|
Probable Causes
?
|
這個
key
的值對沒有在資源文件
ApplicationResources.properties
中定義。如果你使用
eclipse
時經(jīng)常碰到這樣的情況,當項目重新編譯時,
eclipse
會自動將
classes
目錄下的資源文件刪除。
?
|
資源文件
ApplicationResources.properties
?
不在
classpath
中
應將資源文件放到
WEB-INF/classes
?
目錄下,當然要在
struts-config.xml
中定義
)
|
異常
?
|
Cannot find message resources under key org.apache.struts.action.MESSAGE
?
|
可能原因
?
|
很顯然,這個錯誤是發(fā)生在使用資源文件時,而
Struts
沒有找到資源文件。
|
Implicitly trying to use message resources that are not available (such as using empty
html:options
tag instead of specifying the options in its body -- this assumes options are specified in
ApplicationResources.properties
file)
?
|
XML parser issues -- too many, too few, incorrect/incompatible versions
?
|
錯誤
?
|
No input attribute for mapping path /xxxxAction
?
|
可能原因
e
?
|
No
input
attribute in action mapping in
struts-config.xml
file for the action with the name specified in the error message. An
input
attribute is not required if form validation is not performed (either because the
validate
attribute is set to
false
or because the validation method in the relevant form class is not implemented. The
input
attribute specifies the page leading to this action because that page is used to display error messages from the form validation
|
錯誤
?
|
Strange and seemingly random characters in HTML and on screen, but not in original JSP or servlet.
?
|
可能原因
?
|
混和使用
Struts
的
html:form
標記和標準的
HTML
標記不正確。
?
|
使用的編碼樣式在本頁中不支持。
?
|
錯誤
?
|
"Document contained no data" in Netscape
?
|
No data rendered (completely empty) page in Microsoft Internet Explorer
?
|
可能原因
?
|
使用一個
Action
的派生類而沒有實現(xiàn)
perform()
方法或
execute()
方法。在
Struts1.0
中實現(xiàn)的是
perform()
方法,在
Struts1.1
中實現(xiàn)的是
execute()
方法,但
Struts1.1
向后兼容
perform()
方法。
但你使用
Struts1.1
創(chuàng)建一個
Action
的派生類,并且實現(xiàn)了
execute()
方法,而你在
Struts1.0
中運行的話,就會得到
"Document contained no data" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer.”
的錯誤信息。
|