[Struts] Common abnormal information and solutions

xiaoxiao2021-03-06  36

File names such as struts-config.xml and applicationResources.properties are used by default if you use multiple modules, or specify different resource file names, these names should be modified.

1. "No Bean Found Under Attribute Key XXX" defines an actionform in Struts-Config.xml, but the class specified by the Type property does not exist, the value of the Type property should be the full name of the Form class. Or, in the definition of an action, the ActionForm specified by the Name or Attribute property does not exist.

2, "Cannot Find Bean XXX in Any Scope Generally Request.SetAttribute () in action, then you can get these objects in the steering JSP file (with a TAG or Request.GetaTRibute () method) and display it. This exception is that JSP is to get an object, but the previous action does not set objects to Request (can also be session, servletContext). It may be wrong, please check the TAG of the JSP is generally the Name property, or the parameter value of the getAttribute () method; or if the action logic has a problem without executing the setAttribute () method will turn first. There is another possibly, purely a JSP file problem, such as specifies a ID value, then use this value as the value of Name in the loop, if these two values ​​are different, This exception will appear. (Both is a truth, there is no corresponding object in the request.)

3. "Missing Message for Key" XXX "" lacks the resources required, check if there is resources needed in the ApplicationResources.Properties file, for example:

<

Bean: Message Key

=

"

msg.name.prompt

"

/>

This line of code will find msg.name.prompt resources, and this exception occurs if this resource is not available in AppLiationResources.properties. When using multiple modules, pay attention to the name of the resource file to be used in the struts-config-xxx.xml of the module, otherwise, of course, what resources can not be found, this is also a very easy mistake.

4, "NO Getter Method for Property XXX Of Bean Teacher" This exception information is very clear that JSP is going to take a bean property, but this bean does not have this property. You should check the value of the Property property of a tag in the JSP. For example, the CADE in the following code should be changed to CODE:

<

Bean: Write Name

=

"

TEACHER

"

Property

=

"

cade

"

Filter

=

"

True

"

/>

5, "Cannot Find ActionMappings Or ActionformBeans Collection" to be resolved.

6. "Cannot Retrieve Mapping for Action XXX" Specifies an action = '/ xxx' in the .jsp's

tab, but this Action is not set in Struts-Config.xml.

7, http status 404 - /xxx/xxx.jspforward's Path property points to the JSP page does not exist, please check the path and module, for the action in the same module, the module name should not be included in the path; the module is steering, remember Use conteralative = "true". 8, there is no exception information, showing blank page may be the Forward name used in Action, the Forward name defined in Struts-Config.xml does not match.

9, "The element type" xxx "Must Be Terminated by the matching end-tag" xxx "." This is the format error of the struts-config.xml file, carefully check if it is an integrity XML file, about XML file The format will not be described here.

10. "servlet.init () for servlet action threw exception" General This exception will appear behind the ActionServlet's exception stack information, which pointing out which line of exceptions appear in code. I have encountered a prompt as follows:

Java.lang.NullPointerexception at Org.Apache.struts.Action.ActionServlet.ParsemoduleConfigfile (ActionServlet.java:

1003

) At Org.apache.struts.Action.ActionServlet.initModuleConfig (ActionServlet.java:

955

)

To solve the problem, first download the Struts source package, then insert breakpoints in the 1003th line of ActionServlet.java, and monitor each variable. Very shame, I actually lost the struts-config.xml file, so there was an exception above, and should be accidentally deleted when the CVS is synchronized.

11. "Resources Not De De DEfined for Validator" This is an exception that may occur when using the Validator plugin to verify, then you want to check the validation.xml file, see if the resources used in it do have definitions, FORM name is correct, etc. .

These are the problems I have encountered when I use Struts to do projects, some of which have been surrounded by me, in fact, most of them are selfless. I hope this article can help your development and welcome to add.

转载请注明原文地址:https://www.9cbs.com/read-75678.html

New Post(0)