1. Regarding the problem of uploading images failed
Import the jar package first
commons-fileupload-1.2.,
Then modify editor_config.js
Find and modify the URL and modify it to window.UEDITOR_HOME_URL||"/mypro/ueditor/" where mypro is my project name
imagePath is modified to URL + "upload/"
Suppose our image storage path is ueditor/upload/
Then modify
("") Modify to ("../imageUp");
In this way, set the storage path of the image to ueditor/upload/imageUp
Then if you do not configure the struts2 interceptor, you should be able to upload it successfully. If you need to combine the struts2 interceptor, you need to add another configuration.
The principle is this: create an interceptor yourself, replace the default interceptor, and then filter the paths that do not need to be intercepted, and the rest are still used to use the default interceptor.
First create an interceptor class
public class MyStrutsFilter extends StrutsPrepareAndExecuteFilter {
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) {
HttpServletRequest request = (HttpServletRequest) req;
String url = ();
if (("ueditor/jsp/")) {<SPAN style="WHITE-SPACE: pre"> </SPAN>//This is the filtering of all files in the entire folder
try {
(req, res);
} catch (IOException e) {
();
} catch (ServletException e) {
();
}
} else {
try {
(req, res, chain);// Use the default parent class interceptor, i.e. struts2
} catch (IOException e) {
();
} catch (ServletException e) {
();
}
}
}
}
Then define it in
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="/xml/ns/javaee"
xmlns:xsi="http:///2001/XMLSchema-instance"
xsi:schemaLocation="/xml/ns/javaee
/xml/ns/javaee/web-app_3_0.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file></welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
<!-- Use a custom interceptor here, .jsp does not handle it, and other uses the default interceptor -
Note that the default struts2 interceptor 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>/</location>
</error-page>
</web-app>
This configuration is OK