About the JSP version of the ueditor1.2.5 part of the problem resolution (upload image Failure) _ Page Editor

Source: Internet
Author: User

1. Questions about uploading pictures failed

First Import Jar Pack
Commons-fileupload-1.2.2.jar,ueditor.jar

Then modify the Editor_config.js

Locate and modify the URL modification to window. ueditor_home_url| | " /mypro/ueditor/"Where Mypro is the name of my project

ImagePath modified to URL + "upload/"
Let's say our picture store path is ueditor/upload/

Then modify the imageup.jsp
Up.setsavepath ("") is modified to Up.setsavepath ("". /imageup ");
This sets the storage path for the picture to Ueditor/upload/imageup

Then if you do not configure the Struts2 interceptor in Web.xml, you should be able to upload it successfully, and then if you need to combine the STRUTS2 interceptor, you need to add a different configuration

The idea is to create an interceptor yourself, replace the default interceptor, and then filter the path that you don't want to intercept, and the rest with the default interceptor.

First create an Interceptor class

Copy Code code as follows:

public class Mystrutsfilter extends Strutsprepareandexecutefilter {
public void Dofilter (ServletRequest req, servletresponse Res,
Filterchain chain) {
HttpServletRequest request = (httpservletrequest) req;
String URL = Request.getrequesturi ();
if (Url.contains ("ueditor/jsp/")) {<span style= "White-space:pre" > </span>//this is to filter all files under the entire folder.
try {
Chain.dofilter (req, res);
catch (IOException e) {
E.printstacktrace ();
catch (Servletexception e) {
E.printstacktrace ();
}
} else {
try {
Super.dofilter (req, res, chain)//The Interceptor with the default parent class, that is, struts2
catch (IOException e) {
E.printstacktrace ();
catch (Servletexception e) {
E.printstacktrace ();
}
}
}
}

And then define it in Web.xml.

Copy Code code as follows:

<?xml version= "1.0" encoding= "UTF-8"?>
<web-app version= "3.0"
Xmlns= "Http://java.sun.com/xml/ns/javaee"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee
Http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd ">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
Cn.xyx.web.filter.MyStrutsFilter
<!--use custom interceptors here,. JSP does not do processing, others use the default interceptor-
Note that this replaces the default Struts2 interceptor Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter-->
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
</web-app>

So the configuration is OK

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.