Online HTML editor-ueditor, combined with struts2

Source: Internet
Author: User

If you use the previous configuration under struts2, it is not enough.

Because struts2 filters out the ueditor upload path, the upload fails.

There is not much to do, just write a filter.


Create a class in your src package as follows:


01 import java. io. IOException;

02 import javax. servlet. FilterChain;

03 import javax. servlet. ServletException;

04 import javax. servlet. ServletRequest;

05 import javax. servlet. ServletResponse;

06 import javax. servlet. http. HttpServletRequest;

07

08 import org. apache. struts2.dispatcher. ng. filter. StrutsPrepareAndExecuteFilter;

09

10 public class MyStrutsFilter extends StrutsPrepareAndExecuteFilter {

11 public void doFilter (ServletRequest req, ServletResponse res, FilterChain chain)

12 throws IOException, ServletException {

13 HttpServletRequest request = (HttpServletRequest) req;

14 // unfiltered url

15 String url = request. getRequestURI ();

16 if ("/NewsSystem/ueditor/jsp/imageUp. jsp". equals (url )){

17 // other/jsp/paths are not frequently used, and I have not written them.

18 // System. out. println ("use custom filter" + url );

19 chain. doFilter (req, res );

20} else {

21 // System. out. println ("use default filter ");

22 super. doFilter (req, res, chain );

23}

24}

25}

 

 

 

 

 

 

After writing the filter, rewrite web. xml to let struts2 pass through our own filter.

 

Restart tomcat and check whether it is okay.

 

 

Then, the ueditor data is obtained on other pages.

 

 

 

Then, the database information is extracted and put into ueditor as the default content:

 


 

 

 


 

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.