Commons-io cannot obtain the file solution Uploaded By upload. parserequest (request) in the Struts Framework

Source: Internet
Author: User

Commons-io cannot get upload in Struts framework. the main reason for parserequest (request) Upload is that struts encapsulates the request. During file upload, Struts converts the httpservletrequest request to multipartrequestwrapper. If you need to use the request, the multipartrequestwrapper encapsulated by struts needs to be converted to httpservletrequest. Here, two operations are required:

Operation 1: Create a Java class and inherit from jakartamultipartrequest. The Code is as follows:

Public class requestparsewrapper extends jakartamultipartrequest {

Public void parse (httpservletrequest servletrequest, string savedir) throws ioexception {
}
}

Operation 2: Add the following code to the struts configuration file:

<! -- The value of servletfileupload. parserequest (request) cannot be obtained when the file is uploaded. -->

<Bean type = "org. Apache. struts2.dispatcher. multipart. multipartrequest"
Name = "myrequestparser" class = "com. turui. util. requestparsewrapper"
Scope = "default" Optional = "true"/>

<Constant name = "struts. multipart. Handler" value = "myrequestparser"/>

The class here refers to the Java class created in operation 1.



This article is from the "Twain" blog, please be sure to keep this source http://6548877.blog.51cto.com/6538877/1433826

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.