可能原因
特别提示:因为有很多中情况会导致这个错误的发生,所以推荐大家调高你的web服务器的日志/调试级别,这样可以从更多的信息中看到潜在的、在试图创建action类时发生的错误,这个action类你已经在strutsconfig.xml中设置了关联(即添加了
在strutsconfig.xml中通过action标签的class属性指定的action类不能被找到有很多种原因,例如:定位编译后 的.class文件失败。Failure to place compiled .class file for the action in the classpath (在web开发中,class的的位置在r WEBINF/classes,所以你的action class必须要在这个目录下。例如你的action类位于WEBINF/classes/action/Login.class,那么在strutsconfig.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标记
异常
java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm
可能原因
这个错误主要发生在在classpath中找不到相应的Java .class文件。如果这个错误发生在web应用程序的运行时,主要是因为指定的class文件不在web server的classpath中(/WEBINF/classes 和/WEBINF/lib)。在上面的错误中,原因是找不到ActionForm类。
异常
javax.servlet.jsp.JspException: Exception creating bean of class org.apache.struts.action.ActionForm: {1}
可能原因
Instantiating Strutsprovided ActionForm class directly instead of instantiating a class derived off ActionForm. This mightoccur implicitly if you specify that a formbean is this Struts ActionForm class rather than specifying a child of this classfor the formbean.
Not associating an ActionFormdescended class with an action can also lead to this error.
异常
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
可能原因
不是标识Struts actionServlet的
在strutsconfig.xml中的打字或者拼写错误也可导致这个异常的发生。例如缺少一个标记的关闭符号/>。最好使用struts console工具检查一下。
另外,loadonstartup必须在web.xml中声明,这要么是一个空标记,要么指定一个数值,这个数值用来表servlet运行的优先级,数值越大优先级越低。
还有一个和使用loadonstartup有关的是使用Struts预编译JSP文件时也可能导致这个异常。
异常
java.lang.NullPointerException at org.apache.struts.util.RequestUtils.forwardURL(RequestUtils.java:1223)
可能原因
在strutsconfig.xml中的forward元素缺少path属性。例如应该是如下形式:
异常
javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
Probable Causes
试图在Struts的form标记外使用form的子元素。这常常发生在你在后面使用Struts的html标 记。另外要注意可能你不经意使用的无主体的标记,如
异常
javax.servlet.jsp.JspException: Missing message for key xx.xx.xx
Probable Causes
这个key的值对没有在资源文件ApplicationResources.properties中定义。如果你使用eclipse时经常碰到这样的情况,当项目重新编译时,eclipse会自动将classes目录下的资源文件删除。
资源文件ApplicationResources.properties 不在classpath中应将资源文件放到WEBINF/classes 目录下,当然要在strutsconfig.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 specifyingthe 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 render