1. Create a filter
1 PackageCn.lddxfs.tieba.filter;2 3 Importjava.io.IOException;4 5 ImportJavax.servlet.FilterChain;6 Importjavax.servlet.ServletException;7 Importjavax.servlet.ServletRequest;8 ImportJavax.servlet.ServletResponse;9 Importjavax.servlet.http.HttpServletRequest;Ten One ImportOrg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter; A - Public classMystruts2filterextendsStrutsprepareandexecutefilter { - the Public voidDoFilter (servletrequest req, servletresponse Res, -Filterchain chain)throwsIOException, servletexception { -HttpServletRequest request =(httpservletrequest) req; - //non-filtered URLs +String URL =Request.getrequesturi (); - + if(Url.endswith ("/ueditor/jsp/controller.jsp")) { ASYSTEM.OUT.PRINTLN ("Custom" +URL); at Chain.dofilter (req, res); - } - Else if(Url.contains ("/ueditor/jsp/upload/")) { -SYSTEM.OUT.PRINTLN ("Custom" +URL); - Chain.dofilter (req, res); - } in Else { -SYSTEM.OUT.PRINTLN ("Default" +URL); to Super. DoFilter (req, res, chain); + } - } the *}
Copy the following ueditor from the jar package to the web-inf/lib/folder
Delete the Web-inf/lib/ueditor-1.1.1.jar and copy the files under UEDITOR/JSP/SRC to the Project Src folder.
Modify
Package Com.baidu.ueditor.hunter the GetPath method in class FileManager:
1 PrivateString getpath (file file) {2 3String Path =Pathformat.format (File.getabsolutepath ());4String myrootstring = This. rootpath.substring (0, This. RootPath5. substring (0, This. Rootpath.length ()-1). LastIndexOf ("/") +1);6 7String MyPath = Path.replace (myrootstring, "/");8 //System.out.println (myPath);9 returnMyPath;Ten}
2. Under Web. XML, add the following:
1 <Filter>2 <Display-name>Mystruts2filter</Display-name>3 <Filter-name>Mystruts2filter</Filter-name>4 <Filter-class>Cn.lddxfs.tieba.filter.MyStruts2Filter</Filter-class>5 </Filter>6 <filter-mapping>7 <Filter-name>Mystruts2filter</Filter-name>8 <Url-pattern>/*</Url-pattern>9 <Dispatcher>REQUEST</Dispatcher>Ten <Dispatcher>FORWARD</Dispatcher> One </filter-mapping>
Also remove the configuration of the default filter for STRUTS2
3. Unzip the ueditor into place, and note that the Ueditor folder is similar to Web-inf.
4. Locate the Ueditor/jsp/config.json file to modify the contents of the file, in the callout. Add a point and the/ueditor/jsp/upload in the file are replaced by./ueditor/jsp/upload
5. Copy the contents of the file ueditor/index.html to the web-inf/index.jsp
Modify the path of the import JS as follows
1 <%@ Page Language="Java"ContentType="text/html; Charset=utf-8"2 pageencoding="UTF-8"%>3 <%@taglib URI="/struts-tags"prefix="s"%>4 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">5 <HTML>6 <Head>7 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">8 <title>Test Ueditor</title>9 <Linkhref= "${pagecontext.request.contextpath}/ba/css/list.css"Ten rel= "stylesheet"> One </Head> A <Scripttype= "Text/javascript"CharSet= "Utf-8"src= "${pagecontext.request.contextpath}/ueditor/ueditor.config.js"></Script> - <Scripttype= "Text/javascript"CharSet= "Utf-8"src= "${pagecontext.request.contextpath}/ueditor/ueditor.all.min.js"> - </Script> the <Body> -。。。
6 Browser input http://localhost:8080/project name/index.jsp, the final effect such as
The Ueditor editor is used in conjunction with the STRUTS2