ueditor1.3.6jsp version in the Struts2 app upload photo "not found upload files" solution

Source: Internet
Author: User

Abstract: ueditor1.3.6jsp version in the struts2 application upload a picture "Upload file not found" solution

When uploading images or attachments using the Ueditor Rich Text editor in the STRUTS2 application, even if the upload path information is configured, the error "Upload file not Found" will appear, the reason for this problem is: When you configure the Struts filter, filter path Settings/* mode, Since the STRUTS2 framework uses the Apache Commons FileUpload component and the built-in Fileuploadinterceptor interceptor to implement uploads by default, the request file domain is encapsulated in the property of a file type in the action. and deletes the file domain in the request, so uploading the file fails.

Here first, the ueditor1.3.6 JSP version of the file upload related configuration.

Directory Structure of the Ueditor

Home we want to configure the basic relative path of ueditor in the Ueditor.config.js file

Next look at the image upload configuration

We can see that the image upload is done through the Imageup.jap of the JSP directory under the Ueditor root directory. Savepath Saving a directory list for a file

will be used in the

The corresponding will be created in the JSP directory upload directory to save the uploaded pictures

Finally we open the Imageup.jsp page and see that the page uses the Uploader.java class, so we need to create a ueditor package under the Classpath and copy the Uploader.java class in

Complete the above configuration, when we upload the file, there will be "No upload files found" prompt.

Solution:

1. Change the way struts configuration/* is *.xx. (due to project reasons, the way I did not kiss, if the reader has experimented, please leave a message, thank you)

2. Write an action instead of the original imageup.jsp page (it seems that the scheme is more troublesome)

3. Define a struts filter yourself, specifying that the JSP pages in the ueditor/jsp/directory are not filtered. (the scheme is relatively simple compared to the previous one)

The filter code is as follows:

Package com. JL. filter;import Java, I-. Ioexception;import javax. servlet. Filterchain;import javax. servlet. Servletexception;import javax. servlet. Servletrequest;import javax. servlet. Servletresponse;import javax. servlet. http. httpservletrequest;import org. Apache. struts2. Dispatcher, n%. filter. Strutsprepareandexecutefilter;PublicClassMystrutsfilterExtendsstrutsprepareandexecutefilter{ @Overridepublic void DoFilter (ServletRequest req, servletresponse res,filterchain chain) throws IOException, servletexception {httpservletrequest request = (httpservletrequest) req; String url = Request. Getrequesturi (); System.out. println (URL); if (Url.contains ("/meeting/ueditor/jsp/")) {System. Out. println ("Using a custom Filter"); Chain. DoFilter (req, res); }else{System.println ("Use default filter"); Super. DoFilter (req, res, chain);    }} 

Modify the struts configuration as follows:
<!--configuring Struts filters--<Filter><Filter-name>struts2</Filter-name><Filter-class>com.jl.filter.mystrutsfilter</Filter-class></Filter><Filter-mapping><filter-name< Span class= "Hljs-tag" >>struts2</< Span class= "Hljs-tag" >filter-name>< Span class= "Hljs-tag" ><url-pattern< Span class= "Hljs-tag" >>/*</url-pattern></filter-mapping< Span class= "Hljs-tag" >>              

To restart the project, and then upload the operation will no longer be wrong oh! ^_^

Finally, I hope you reprint please indicate the source, respect for the work of others http://my.oschina.net/jiangli0502/blog/210263

Reference: Http://www.010cnc.net/subject/about/UEditor%20 and struts2%20 to solve the problem. html

ueditor1.3.6jsp version in the Struts2 app upload photo "not found upload files" solution

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.