STRUTS2 Error Summary oneself will constantly update ....

Source: Internet
Author: User

One, the backstage unceasingly appears "the warning: could not to find the property [Struts.valuestack]"

Solution: No Log4j-xxx.jar, download one, put it under Lib

Second, Java.lang.noclassdeffounderror:org/apache/struts2/dojo/views/jsp/ui/headtag

Workaround: The reason is missing the Dojo Jar package, introduced: Struts2-dojo-plugin-2.1.2.jar

(The ' head ' tag renders required javaScript code to configure Dojo and are required in-order-any of the tags include D in the Dojo plugin.--------------------If your are planning to nest tags from the dojo plugin, make sure your set Parsecon Tent= "false", otherwise each request made by the inner tags would be performed twice. )

Third, unable to load configuration. -bean-jar:file:/f:/struts2/struts2/webroot/web-inf/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178

caused By:unable to load bean:type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:o rg.apache.struts2.dispatcher.multipart.jakartamultipartrequest-bean-jar:file:/f:/struts2/struts2/webroot/ web-inf/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178

caused By:java.lang.noclassdeffounderror:org/apache/commons/fileupload/requestcontext
Workaround: Missing jar packs, introducing Commons-fileupload-1.2.1.jar,commons-io-1.3.2.jar

Four, No tag "DateTimePicker" defined in the tag library imported with prefix "s"

Reason version problem: Missing Struts-dojo-plugin jar package, and,

If you are using Struts 2.1.x you ' re probably missing the> Struts-dojo-plugin. Michaël ' s reference below applies to struts 2.1.xonly. In the lasts versions (since 2.0.9 I guess), all Ajax are in dojo> plugin.
> > so your need to include <%@ taglib uri= "/struts-dojo-tags" prefix= "SX"%>
> > and <sx:head/>
> > (TEMP1:
<sx:datetimepicker name= "Picker"/>
TEMP2:
<sx:datetimepicker type= "Time" name= "Picker"/><br/>
Temp3:
<sx:datetimepicker value= "%{' 2008-06-08 '}" name= "Picker"/>
Temp4:
<sx:datetimepicker value= "date" name= "Picker"/>)
> > and call: <sx:datetimepicker .../>

V. Use of the tiles framework

If Use the Tiles 2 plugin, check your tiles.xml file (s) to ensure they contain a DOCTYPE.

<! Tiles-definitions public "-//apache Software foundation//dtd tiles Configuration 2.0//en" DOCTYPE
"Http://tiles.apache.org/dtds/tiles-config_2_0.dtd" >
<tiles-definitions>

El expression Convert el expressions to OGNL is not supported in Struts2

struts2.1 tags do not allow evaluation of JSP EL within their attributes.
Instead, struts2 tags evaluate attribute values as OGNL. allowing both
Expression languages within the same attribute opens major security
Vulnerabilities.

The file upload process can not get the file name and file type, that is, to null

Reason: If the name= "a" of file in the page is set String acontenttype,string afilename in our action (these two don't really matter, the key is the Set method)

SetA (file file) () {}; Setacontenttype (string s) {};setafilename (string name) {} is formatted as follows: Setxcontenttype () Setxfilename (). X means that the name you give file must be the same as it, fixed format


Viii. Serious: Unable to parse request
Org.apache.commons.fileupload.fileuploadbase$sizelimitexceededexception:the request is rejected because its size ( 8523356) exceeds the configured maximum (2097152)
At Org.apache.commons.fileupload.fileuploadbase$fileitemiteratorimpl.<init> (FileUploadBase.java:914) 2008-5-27 17:46:51 Com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
Warning: Could not find property [Struts.valuestack]
2008-5-27 17:46:51 Com.opensymphony.xwork2.util.logging.commons.CommonsLogger Error
Serious: The request was rejected because its size (8523356) exceeds the configured maximum (2097152)
2008-5-27 17:46:51 Com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
Warning: Could not find property [Org.apache.catalina.jsp_file]

Reason: Upload file size exceeds predetermined size, you can set struts.multipart.maxsize=xxx in struts.properties configuration file (XXX is file size)

Nine, the configuration of file type restrictions, when the type of error can intercept the user to upload the file, but the jump page did not jump to the input configuration error page, but return

    to success the correct page.
Critical: Content-type not Allowed:filedata "upload__5b01657_11a329d4dcf__8000_00000000.tmp" Text/plain
My printout of the debug statement content: File:null fliename:null      type:null "The Intercept type succeeded
Java.lang.NullPointerException
at java.io.fileinputstream.<init> (fileinputstream.java:103)
at Com.study.web.util.FileUploadUtil.uploadFile (fileuploadutil.java:36)
at Com.study.web.action.UploadFileAction.execute (uploadfileaction.java:58)
at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method) ...

2008-5-29 10:59:07 Com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
Warning: Could not find property [Org.apache.catalina.jsp_file]
2008-5-29 10:59:07 Com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
Warning: Could not find property [struts]
2008-5-29 10:59:07 Com.opensymphony.xwork2.util.logging.commons.CommonsLogger Info
Info: Removing file filedata/tmp/upload__5b01657_11a329d4dcf__8000_00000000.tmp

Cause and solution: After the file upload action only configured fileuploadinterceptor after the lack of configured Defaultstack interceptor.

The error disappears after configuring the Defaultstack interceptor in the action.

Ten, the global configuration file size in the Struts.properties, and then use the default Fileuploadinterceptor interceptor can be implemented to intercept the function but the background appears abnormal.

Serious: Unable to parse request Org.apache.commons.fileupload.fileuploadbase$sizelimitexceededexception:the request was Rejected because its size (380) exceeds the configured maximum (10)
At Org.apache.commons.fileupload.fileuploadbase$fileitemiteratorimpl.<init> (FileUploadBase.java:914)

Reason: Unknown. Remove the restrictions in the global configuration, and then override the Configure Fileuploadinterceptor Interceptor setting size and file type limit in the action to eliminate the exception.

Xi. multiple file crosses, one of which is restricted to a file such as restricting Aplication/msword (that is, a. doc) file, allowing text files to be passed. However, when the inclusions are transmitted together, the background can intercept the type error is not transmitted information, but

In fact, but still upload success.

Serious: Content-type not Allowed:filedata "Upload_4d958287_11a33e76ab9__8000_00000007.tmp" Application/msword
File is:/tmp/upload_4d958287_11a33e76ab9__8000_00000006.tmp fileName:project.txt filetype:text/plain
File is:/tmp/upload_4d958287_11a33e76ab9__8000_00000007.tmp filename:application base.doc fileType:application/ MSWord
File is:/tmp/upload_4d958287_11a33e76ab9__8000_00000008.tmp filename:zhongqi-bug.txt fileType:text/plain

Reason: Forgot to inherit the Actionsupport class. The exception disappears after inheritance.

12, File upload exception, can not create file files

Cannot create type class Java.io.File from Value C:/Documents and settings/admin/desktop/orderreporterserviceimp.java-[unkno WN Location]

Reason: Forgot to set enctype in form form to file upload format: enctype= "Multipart/form-data"

13. Throw null pointer exception when using limit file type and size

Java.lang.NullPointerException
Demo.struts2.action.ValidatFileUploadAction.execute (validatfileuploadaction.java:71)
Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
Cause: After configuring the FileUpload interceptor in action, I forgot to configure the default interceptor: Defautlstack. Note Configuration defaults are required when you configure your interceptor in the action

Interceptor Defaultstack

14, in the internationalization of the time to throw null pointer exception:

16:31:12,812 ERROR [Jsp]:253-servlet.service () for Servlet JSP threw exception
Java.lang.NullPointerException at Java.text.MessageFormat.applyPattern (messageformat.java:414)

At Java.text.messageformat.<init> (messageformat.java:350)
At Com.opensymphony.xwork2.DefaultTextProvider.getText (defaulttextprovider.java:70)

Reason: Forgot to configure Internationalized constants in Struts.xml, or configure global internationalization constants in Struts.properties Struts.custom.i18n.resources=globemessage

The configuration file for the struts action failed to load:

Unable to load configuration. -Result-file:/d:/java/apache-tomcat-5.5.20/webapps/mysts/web-inf/classes/test.xml:10:26

caused By:no result type specified to result named ' Error ', perhaps the parent package does not specify the result type? -Result-file:/d:/java/apache-tomcat-5.5.20/webapps/mysts/web-inf/classes/test.xml:10:26
At Com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults (Xmlconfigurationprovider.java : 609)

Reason: Forgot inheritance package Struts-default

16, Struts action profile considerations:

1. Don't forget to inherit struts-default default configuration Package

2. If you configure the namespace, be sure to start with "/", for example: namespace= "/test"

3. The global Result,global-result can be configured in each module struts action configuration file, and Strtus will intelligently look for the action request

Module Struts Action Configuration package

17, JSP in the <s:optiontransferselect/> label has been normal display use

<s:optiontransferselect tooltip= "User Rights" label= "Set Permissions"
Name= "Mhpopedom.leftlist_1"
Lefttitle= "User not authorized Limit"
List= "Leftlist_1"
listkey= "Popeid"
Listvalue= "Popename"
headerkey= "Headerkey"
Multiple= "true"
Emptyoption= "false"
Allowupdownonleft= "false"
Cssstyle= "width:200px;height:300px;"
Cssclass= "Input2"

Addtoleftlabel= "Move Left"
Addtorightlabel= "Move Right"
Addalltoleftlabel= "Move all Left"
Selectalllabel= "Select All"
Addalltorightlabel= "Move All Right"

Doublename= "Rightpopedom"
righttitle= "User Authorized Limit"
Doublelist= "Rightlist_1"
doublelistkey= "Popeid"
Doublelistvalue= "Popename"
doubleheaderkey= "Doubleheaderkey"
Doublemultiple= "true"
Doubleemptyoption= "false"
Allowupdownonright= "false"
Doublecssclass= "Input2"
Doublecssstyle= "width:200px;height:300px;" >
</s:optiontransferselect>
However, no matter how the Rightpopedom value is not obtained in the action, the null pointer exception is reported.

Solution:

Background action Add attributes (Setxxx and GetXXX methods):
Private string[] leftlist;
Private string[] rightlist;

On the foreground page, when submitting the form, the OnClick event calls the following JS:
<script type= "Text/javascript" >
function myself () {
var right=document.forms[0].rightlist;
For (I=1 i <right.length; i++)
Right[i].selected = true;
}
</script>
After submitting, you can get the value inside the rightlist in the background.
If you do not have this JS code, the background is not a value, this is the struts2 <s:optiontransferselect/> itself bug.

The second solution:

Using <s:submit/> in form can also fetch values

18, "Strutsutils undefined" error

struts2.1.6
S:optiontransferselect
Struts2 JS not loaded

has been added <s:head/>
Source file production:
<script src= "/xxxx/struts/utils.js" type= "Text/javascript" ></script>

Reason:
In Web.xml
Struts did not intercept JS files, you need to add such as:

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.js</url-pattern>
</filter-mapping>

Or
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/struts/*</url-pattern>
</filter-mapping>

To remind: all the paths are filtered will not appear in this situation, some video and book tutorials, the default is <url-pattern>/**</url-pattern>, have all the paths have been filtered, see other people's no problem, But to really develop their own, the problem is full of mistakes, whining ...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.