1. Questions about Image Upload failure
First import the jar package
Commons-fileupload-1.2.2.jar, ueditor. jar
Modify editor_config.js
Find and modify the URL to window. UEDITOR_HOME_URL | "/mypro/ueditor/". mypro is the name of my project.
Modify imagePath to URL + "upload /"
Suppose our image storage path is ueditor/upload/
Modify imageUp. jsp
Up. setSavePath ("") to up. setSavePath ("../imageUp ");
In this way, set the image storage path to ueditor/upload/imageUp.
If the struts2 interceptor is not configured in web. xml, the upload should be successful. If you need to combine the struts2 interceptor, you need to add additional configurations.
The principle is to create an interceptor, replace the default interceptor, and filter the paths that do not need to be intercepted.
First, create an interceptor class.
Copy codeThe Code is 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> // filter all files in the folder.
Try {
Chain. doFilter (req, res );
} Catch (IOException e ){
E. printStackTrace ();
} Catch (ServletException e ){
E. printStackTrace ();
}
} Else {
Try {
Super. doFilter (req, res, chain); // use the interceptor of the default parent class, that is, struts2
} Catch (IOException e ){
E. printStackTrace ();
} Catch (ServletException e ){
E. printStackTrace ();
}
}
}
}
Then define in web. xml
Copy codeThe Code is 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
<! -- The Custom interceptor is used here, And. jsp is not processed. Others use the default Interceptor-
Note that the default struts2 interceptor org. apache. struts2.dispatcher. ng. filter. StrutsPrepareAndExecuteFilter is replaced here -->
</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>
In this way, you can configure