`
laorer
  • 浏览: 435776 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

<转>Struts常见错误及原因

    博客分类:
  • j2EE
阅读更多
<!---->

<!---->

说明:此文是MSC从网上下载并整理的。谢谢msc哦!

Struts常见错误及原因
Common Struts Errors and Causes
...............

http://www2.matrix.org.cn/thread.shtml;jsessionid=6D41C5F001A249924CD5983AA7853222?topicId=2624&forumId=22

.........................


This page contains errors and exceptions commonly encountered during web application development using Struts. Along with the exception or error messages themselves, potential causes of these errors are often listed along with links to additional resources.
To find the error you&#39;re looking for, use your browser&#39;s Find or Search capability and input a few words that you are seeing in your error message.
Cannot retrieve mapping for action
错误信息 javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login
可能原因
lNo action defined in struts-config.xml to match that specified in the JSP&#39;s  <html:form action="Login.do".
相关链接
No action instance for path /xxxx could be created
错误信息 No action instance for path /xxxx could be created
可能原因
lSpecial Note: Because so many different things can cause this error, it is recommended that you turn your error logging/debugging levels on your web server to a high level of verbosity to see the underlying problems in trying to instantiate the action class you have written and associated with the specified action xxxx through an action mapping in the struts-config.xml file.
lYour Action class specified in the struts-config.xml file under the class attribute of the action mapping for action xxxx cannot be found for a variety of reasons, including (but not limited to): ·Failure to place compiled .class file for the action in the classpath (needs to be under WEB-INF/classes with the appropriate directory structure underneath this that matches the package your Action class belongs to). ·Package spelling or hierarchy specified in your action class itself (using the package keyword) does not match the spelling or complete package hierachy specified for your action class in the class attribute of the action in struts-config.xml.
lAction class specified in the /xxxx action mapping in the struts-config.xml file (class attribute) does not extend (directly or indirectly) from the Action class. In other words, your custom Action class does not extend off the Struts-provided Action class or off of another class that eventually extends the Action class (such as DispatchAction.
lProblem in your classpath, such as web server not being able to find ApplicationResources.properties files in the WEB-INF/classes/ directory or specified subdirectory.
lProblem in struts-config.xml file with action mapping.
lProblem with data-sources.xml file.
相关链接
lApplication&#39;s Action classes does not extend Struts-provided Action class·
lPackage hierarchy/directory structure specified in struts-config.xml file differs from that hierarchy specified in the actual action class&#39;s file using the package keyword.http://www.mail-archive.com/struts-user@jakarta.apache.org/msg65874.html ·
lAction Mapping mistake in struts-config.xml:http://www.manning.com/ao/readforum.html?forum=siaao&readthread=177 ·data-sources.xml file?:http://www.caucho.com/quercus/faq/section.xtp?section_id=30
No getter method for property XXXX of bean org.apache.struts.taglib.html.BEAN
错误信息 javax.servlet.jsp.JspException: No getter method for property username of bean org.apache.struts.taglib.html.BEAN
可能原因
lNo getXXXX() method defined for form field with name XXXX
lThis can happen if the JSP/Struts developer forgets that the name of the get method will have the same spelling as the value supplied in the Struts tag&#39;s property attribute, but that case will be different and is based on JavaBean specification rules. For example, my form class should have a getUsername method if my Struts form-related tag has username as the value for its property attribute. Note the difference in case marked with emphasis on the letter "U."
相关链接
lCase can trip up the matching between get method&#39;s name and name specified in Struts taghttp://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=000163
Exception creating bean of class org.apache.struts.action.Actionform: {1}
错误信息 javax.servlet.jsp.JspException: Exception creating bean of class org.apache.struts.action.Actionform: {1}
可能原因
lInstantiating 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.
lNot associating an Actionform-descended class with an action can also lead to this error.
Cannot find ActionMappings or ActionformBeans collection
错误信息 javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionformBeans collection
可能原因
lEither the <servlet> tags for the Struts action servlet or the <servlet-mapping> tags for the .do extension mapping or both not present in the web.xml file. I saw a case where the web.xml file had no elements other than the root element and so this error was occurring.
lTypos or spelling errors in the struts-config.xml can lead to this error message. For example, missing a slash ("/") on a closing tag can have this effect.
lAnother element that must be present in the web.xml file is the load-on-startup element. This can be either an empty tag or can have an integer specified that indicates the priority of executing the associated servlet. The higher the number in the load-on-startup tags, the lower its priority.
相关链接

NullPointerException at ... RequestUtils.forwardURL
错误信息 java.lang.NullPointerException at org.apache.struts.util.RequestUtils.forwardURL (RequestUtils.java:1223)
可能原因
lMissing path attribute in the forward subelement of the action element in struts-config.xml
相关链接
Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
错误信息 javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
可能原因
lTrying to use Struts form subelement tags outside of the Struts&#39; form tag.
相关链接
lUsing form subelements outside of a form tag http://forum.java.sun.com/thread.jsp?thread=337537&forum=4&message=1384153  
Missing message for key xx.xx.xx
错误信息 javax.servlet.jsp.JspException: Missing message for key xx.xx.xx
可能原因
lThe key-value pair with specified key is not in ApplicationResources.properties file
lApplicationResources.properties file not in classpath (not in WEB-INF/classes directory in specified location)
相关链接  
Cannot find message resources under key org.apache.struts.action.MESSAGE
错误信息 Cannot find message resources under key org.apache.struts.action.MESSAGE
可能原因
lExplicitly trying to use message resources that are not available (such as ApplicationResources.properties not available
lImplicitly 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)
lXML parser issues -- too many, too few, incorrect/incompatible versions
相关链接
lXML Parser Issues http://www.mail-archive.com/struts-user@jakarta.apache.org/msg15779.html

No input attribute for mapping path /loginAction
错误信息 No input attribute for mapping path /xxxxAction
可能原因
lNo 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 Output Characters (页面乱码)
错误信息 Strange and seemingly random characters in HTML and on screen, but not in original JSP or servlet.
可能原因
lRegular HTML form tags intermixed incorrectly with Struts html:form tags.
HTML标签与Struts标签不正确的混合使用
lEncoding style used does not support characters used in page.
使用了JSP页面不支持的编码
相关链接
"Document contained no data" or no data rendered on page (空白页面)
错误信息
l"Document contained no data" in Netscape (在Netscape中显示“文件中无数据”)
lNo data rendered (completely empty) page in Microsoft Internet Explorer(在IE中为空白页面,无任何显示信息)
可能原因
lEmploying a descendent of the Action class that does not implement the perform() method while using the Struts 1.0 libraries. Struts 1.1 Action child classes started using execute() rather than perform(), but is backwards compatible and supports the perform() method. However, if you write an Action-descended class for Struts 1.1 with an execute() method and try to run it in Struts 1.0, you will get this "Document contained no data" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer.
l用Struts1.1写的应用在struts1.0环境中运行时,可能出现此问题。
相关链接


其它错误信息
编译JSP文件时出现错误:
java.lang.NullPointerException
error:org.apache.jasper.JasperException: Error compiling \JSPs\security\appUserCreate.jsp
可能原因:
JSP页面中的Struts标记有语法错误。
例如:<bean:message key=”button.submit”> 错误原因:右边的括号前缺少斜杠“/”
正确的为:<bean:message key=”button.submit”/>

不同语言资源文件中的Key不匹配。

分享到:
评论

相关推荐

    Struts常见错误及原因分析

    以下是对几个常见错误及其原因的详细分析: 1. 异常 javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login 这个错误表明在struts-config.xml中没有为/L Login定义Action Mapping。确保在...

    【开发经验】Struts常见错误及原因分析 .doc

    以下是一些常见的Struts错误及其原因和解决方案: 1. 异常`javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login` 这个错误表明在`struts-config.xml`中没有为`/Login`动作定义映射,或者...

    Struts常见错误及原因分析.

    ### Struts常见错误及原因分析 #### 一、异常 javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login **异常描述**: 该异常通常出现在尝试访问一个未在`struts-config.xml`文件中正确配置...

    struts多文件上传

    &lt;groupId&gt;org.apache.struts&lt;/groupId&gt; &lt;artifactId&gt;struts2-core&lt;/artifactId&gt; &lt;version&gt;2.x&lt;/version&gt; &lt;/dependency&gt; &lt;!-- Commons FileUpload --&gt; &lt;dependency&gt; &lt;groupId&gt;commons-fileupload&lt;/groupId&gt; ...

    struts2环境搭建及国际化

    &lt;artifactId&gt;struts2-json-plugin&lt;/artifactId&gt; &lt;version&gt;${struts2.version}&lt;/version&gt; &lt;/dependency&gt; &lt;!-- 其他依赖如log4j等 --&gt; &lt;/dependencies&gt; ``` - **步骤3:** 设置Java编译版本,在pom.xml中添加或...

    struts2上传文件

    &lt;groupId&gt;org.apache.struts&lt;/groupId&gt; &lt;artifactId&gt;struts2-core&lt;/artifactId&gt; &lt;version&gt;2.x.x&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;commons-fileupload&lt;/groupId&gt; &lt;artifactId&gt;commons-...

    java文件上传到服务器

    &lt;artifactId&gt;struts&lt;/artifactId&gt; &lt;version&gt;1.3.10&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;commons-fileupload&lt;/groupId&gt; &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt; &lt;version&gt;1.4&lt;/version&gt; &lt;/...

    struts开发错误总汇

    本文将针对“struts开发错误总汇”这一主题,详细解析一个常见的错误:缺少`spring-Hibernate`文件。 在描述中提到的错误涉及到Spring和Hibernate的集成,具体是`org.springframework.orm.hibernate3....

    struts2实现上传

    &lt;param name="excludeParams"&gt;dojo\..*,^struts\..*&lt;/param&gt; &lt;/interceptor-ref&gt; &lt;result name="success"&gt;/success.jsp&lt;/result&gt; &lt;result name="input"&gt;/upload.jsp&lt;/result&gt; &lt;/action&gt; &lt;/package&gt; ``` 接着,...

    struts常见错误以及解决

    ### Struts 常见错误及其解决方案 #### 一、`Servlet.service() for servlet jsp threw exception` 在Struts框架的开发过程中,我们经常会遇到一些常见的异常情况,这些异常不仅会打断我们的工作流程,还会影响到...

    Struts常见错误汇总

    ### Struts 常见错误汇总与解析 #### 1. No bean found under attribute key XXX **问题描述:** 在使用 Struts 框架进行 Java Web 开发时,经常会出现找不到对应属性键下的 Bean 的情况。这通常发生在 `...

    struts2实现文件上传(单个+多个文件上传

    &lt;interceptor name="fileUploadInterceptor" class="org.apache.struts2.interceptor.FileUploadInterceptor"&gt; &lt;param name="maximumFileSize"&gt;10000000&lt;/param&gt; &lt;param name="maximumSizeExceededMessage"&gt;${...

    Struts2实现多文件上传

    在Struts2中,实现多文件上传功能是常见的需求,尤其在处理用户需要上传多个文件的场景下,如上传图片、文档等。本篇文章将详细介绍如何使用Struts2来实现这一功能。 首先,我们需要理解Struts2的上传机制。在...

    Struts2 框架搭建(基本)和几个报错问题

    &lt;groupId&gt;org.apache.struts&lt;/groupId&gt; &lt;artifactId&gt;struts2-core&lt;/artifactId&gt; &lt;version&gt;2.5.x&lt;/version&gt; &lt;/dependency&gt; ``` 其中`2.5.x`是Struts2的版本号,确保使用最新的稳定版本。 3. **配置Web.xml**:...

    Struts常见错误汇总.txt

    ### Struts 常见错误汇总与解析 #### 一、Nobean found under attribute key XXX 在 Struts 框架中,如果在请求作用域(request scope)中查找某个 ActionForm bean 时未找到,则会抛出此异常。这通常是因为在 `...

    struts十大验证框架

    &lt;message&gt;转换错误,请输入正确的年龄&lt;/message&gt; &lt;/field-validator&gt; ``` #### 四、配置详解 每一种验证类型都支持不同的参数,如`&lt;param&gt;`标签用于指定验证的具体参数,`&lt;message&gt;`标签用于定义验证失败时的...

    struts标签问题

    5. **常见错误与解决** - **找不到标签库**:检查`struts-tags.tld`或`struts-bean.tld`等是否已引入到JSP头部。 - **属性绑定失败**:确认Action类的属性与标签的`name`属性匹配,且访问修饰符为`public`。 - **...

    使用idea搭建SSM(meavn)项目

    SSM(Spring、Struts、Mybatis)与MEVN(MongoDB、Express、Vue.js、Node.js)是两种常见的Web开发框架。本文将详细介绍如何在IntelliJ IDEA(简称Idea)中搭建SSM项目,并解决新手可能遇到的问题。 首先,我们需要...

Global site tag (gtag.js) - Google Analytics