异常
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处理,若是出现上述异常,请查看struts-config.xml中的定义部分,有时多是打错了字符或者是某些不符合规则,可使用struts
console工具来检查。
-----------------------------------------------------------------------------------------------------------------
异常
org.apache.jasper.JasperException: Cannot retrieve definition for form bean null
可能缘由
这个异常是由于Struts根据struts-config.xml中的mapping没有找到action指望的form bean。大部分的状况多是由于在form-bean中设置的
name属性和action中设置的name属性不匹配所致。换句话说,action和form都应该各自有一个name属性,而且要精确匹配,包括大小写。这个
错误当没有name属性和action关联时也会发生,若是没有在action中指定name属性,那么就没有name属性和action相关联。固然当action制做
某些控制时,譬如根据参数值跳转到相应的jsp页面,而不是处理表单数据,这是就不用name属性,这也是action的使用方法之一。
-----------------------------------------------------------------------------------------------------------------
异常
No action instance for path /xxxx could be created
可能缘由
特别提示:由于有不少中状况会致使这个错误的发生,因此推荐你们调高你的web服务器的日志/调试级别,这样能够从更多的信息中看到潜在
的、在试图建立action类时发生的错误,这个action类你已经在struts-config.xml中设置了关联(即添加了<action>标签)。
在struts-config.xml中经过action标签的class属性指定的action类不能被找到有不少种缘由,例如:
定位编译后的.class文件失败。Failure to place compiled .class file for the action in the classpath (在web开发中,class的的位置
在r WEB-INF/classes,因此你的action class必需要在这个目录下。例如你的action类位于WEB-INF/classes/action/Login.class,那么在
struts-config.xml中设置action的属性type时就是action.Login).
拼写错误,这个也时有发生,而且不易找到,特别注意第一个字母的大小写和包的名称。
-----------------------------------------------------------------------------------------------------------------
异常
javax.servlet.jsp.JspException: No getter method for property username of bean org.apache.struts.taglib.html.BEAN
可能缘由
没有位form bean中的某个变量定义getter 方法
这个错误主要发生在表单提交的FormBean中,用struts标记<html:text property=”username”>时,在FormBean中必须有一个getUsername()
方法。注意字母“U”。
-----------------------------------------------------------------------------------------------------------------
异常
java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm
可能缘由
这个错误主要发生在在classpath中找不到相应的Java .class文件。若是这个错误发生在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.
Not associating an ActionForm-descended class with an action can also lead to this error.
-----------------------------------------------------------------------------------------------------------------
异常
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
可能缘由
不是标识Struts actionServlet的<servlet>标记就是映射.do扩展名的<sevlet-mapping>标记或者二者都没有在web.xml中声明。
在struts-config.xml中的打字或者拼写错误也可致使这个异常的发生。例如缺乏一个标记的关闭符号/>。最好使用struts console工具检查一
下。
另外,load-on-startup必须在web.xml中声明,这要么是一个空标记,要么指定一个数值,这个数值用来表servlet运行的优先级,数值越大优
先级越低。
还有一个和使用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"/>
-----------------------------------------------------------------------------------------------------------------
异常
javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
Probable Causes
试图在Struts的form标记外使用form的子元素。这经常发生在你在</html:form>后面使用Struts的html标记。
另外要注意可能你不经意使用的无主体的标记,如<html:form … />,这样web 服务器解析时就看成一个无主体的标记,随后使用的全部
<html>标记都被认为是在这个标记以外的,如又使用了<html:text property=”id”>
还有就是在使用taglib引入HTML标记库时,你使用的prefix的值不是html。
-----------------------------------------------------------------------------------------------------------------
异常
javax.servlet.jsp.JspException: Missing message for key xx.xx.xx
Probable Causes
这个key的值对没有在资源文件ApplicationResources.properties中定义。若是你使用eclipse时常常碰到这样的状况,当项目从新编译时,
eclipse会自动将classes目录下的资源文件删除。
资源文件ApplicationResources.properties 不在classpath中应将资源文件放到 WEB-INF/classes 目录下,固然要在struts-config.xml中
定义)
-----------------------------------------------------------------------------------------------------------------
异常
Cannot find message resources under key org.apache.struts.action.MESSAGE
可能缘由
很显然,这个错误是发生在使用资源文件时,而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
-----------------------------------------------------------------------------------------------------------------
异常
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的派生类而没有实现perform()方法或execute()方法。在Struts1.0中实现的是perform()方法,在Struts1.1中实现的是
execute()方法,但Struts1.1向后兼容perform()方法。
但你使用Struts1.1建立一个Action的派生类,而且实现了execute()方法,而你在Struts1.0中运行的话,就会获得"Document contained no
data" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer.”的
错误信息。
---------------------------------------------------------------------------------------------------------------------------
异常
ServletException: BeanUtils.populate
解决方案
在用Struts上传文件时,遇到了javax.servlet.ServletException: BeanUtils.populate异常。
个人ActionServlet并无用到BeanUtils这些工具类。后来仔细检查代码发现是在jsp文件里的form忘了加enctype="multipart/form-
data" 了。因此写程序遇到错误或异常应该从多方面考虑问题存在的可能性,想到系统提示信息之外的东西。
----------------------------------------------------------------------------------------------------------------------------
1. 定义Action后, 若是指定了name, 那么必需要定义一个与它同名的FormBean才能进行form映射.
2. 若是定义Action后, 提交页面时出现 "No input attribute for mapping path..." 错误, 则须要在其input属性中定义转向的页面.
3. 若是插入新的数据时出现 "Batch update row count wrong:..." 错误, 则说明XXX.hbm.xml中指定的key的类型为原始类型(int, long),
由于这种类型会自动分配值, 而这个值每每会让系统认为已经存在该记录, 正确的方法是使用java.lang.Integer或java.lang.Long对象.
4. 若是插入数据时出现 "argument type mismatch" 错误, 多是你使用了Date等特殊对象, 由于struts不能自动从String型转换成Date型,
因此, 你须要在Action中手动把String型转换成Date型.
5. Hibernate中, Query的iterator()比list()方法快不少.
6. 若是出现 "equal symbol expected" 错误, 说明你的strtus标签中包含另外一个标签或者变量, 例如:
<html:select property="test" onchange="<%=test%>"/>
或者
<html:hidden property="test" value="<bean:write name="t" property="p"/>"/>
这样的状况...
---------------------------------------------------------------------------------------------------------------------------
错误:
Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
缘由与解决:
由于Hibernate Tools(或者Eclipse自己的Database Explorer)生成*.hbn.xml工具中包含有catalog="***"(*表示数据库名称)这样的
属性,将该属性删除就能够了
---------------------------------------------------------------------------------------------------------------------------
错误:
org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)
缘由与解决:
方法1 删除Set方的cascade
方法2 解决关联关系后,再删除
方法3 在many-to-one方增长cascade 但值不能是none
最后一招:
检查一下hashCode equals是否使用了id做为惟一标示的选项了;我用uuid.hex时是没有问题的;可是用了native,就不行了,怎么办?删除啊
!
----------------------------------------------------------------------------------------------------------------------------
问题:
今天用Tomcat 5.5.12,发现原来很好用的系统不能用了,反复测试发现页面中不能包含 taglib,不然会出现如下提示:
HTTP Status 500 -type Exception report
Message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /index.jsp(1,1) Unable to read TLD "META-INF/tlds/struts-bean.tld" from JAR file
"file:*****/WEB-INF/lib/struts.jar":
缘由:
更新了工程用的lib文件夹下的jar,发布时也发布了servlet.jar和jsp-api.jar。
解决:
把jsp-api.jar删除就解决这个问题了。
-----------------------------------------------------------------------------------------------------------------------------
错误: java.lang.NullPointerException
缘由: 发现 dao 实例、 manage 实例等须要注入的东西没有被注入(俗称空指针异常)
解决:这个时候,你应该查看日志文件;默认是应用服务器的 log 文件,好比 Tomcat 就是 [Tomcat 安装目录 ]/logs ;你会发现提示你:
多是:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sf' defined in ServletContext
resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is
org.hibernate.HibernateException: could not configure from URL: file:src/hibernate.cfg.xml
org.hibernate.HibernateException: could not configure from URL: file:src/hibernate.cfg.xml
……………………….
Caused by: java.io.FileNotFoundException: src\hibernate.cfg.xml
多是:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in
ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is
org.hibernate.MappingException: Resource: com/mcc/coupon/model/UserRole.hbm.xml not found
org.hibernate.MappingException: Resource: com/mcc/coupon/model/UserRole.hbm.xml not found
而后你就知道缘由是由于配置文件的解析出了错误,这个经过 Web 页面是看不出来的。
更多的是持久化影射文件出的错误;致使了没有被解析;固然你须要的功能就没法使用了。
----------------------------------------------------------------------------------------------------------------------------
错误:
StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
javax.servlet.jsp.JspException: Cannot retrieve mapping for action /settlementTypeManage
或者:
type Status report
message Servlet action is not available
description The requested resource (Servlet action is not available) is not available.
缘由: 同 上
----------------------------------------------------------------------------------------------------------------------------
错误
StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.ClassNotFoundException: org.apache.struts.taglib.bean.CookieTei
界面错误具体描述:
org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class: org.apache.struts.taglib.bean.CookieTei
缘由与解决:
<方案一>你的“html:”开头的标签没有放在一个<html:form>中
<方案二>从新启动你的应用服务器,自动就没有这个问题了