1, Ueditor.config.js, the first line
Window. Ueditor_home_url = "/bss/js/ueditor/";
Specify the root directory
2. Custom Filter
PackageCom.baidu.ueditor.filter;ImportJavax.servlet.FilterChain; Importjavax.servlet.ServletRequest; ImportJavax.servlet.ServletResponse; Importjavax.servlet.http.HttpServletRequest; ImportOrg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter; Public classUeditorfilterextendsstrutsprepareandexecutefilter{ Public voidDoFilter (servletrequest req, servletresponse Res, filterchain chain) {HttpServletRequest request=(httpservletrequest) req; String URL=Request.getrequesturi (); Try{ if(Url.length () > && "imageup.jsp". Equals (Url.substring (Url.length ()-11))) {//UmeditorChain.dofilter (req, res); }if(Url.contains ("/bss/js/ueditor/jsp/controller.jsp")) {//UeditorChain.dofilter (req, res); } Else { Super. DoFilter (req, res, chain); } }Catch(Exception e) {e.printstacktrace (); } } }
3. Configure Web. xml
<Filter> <Filter-name>Strutspreparefilter</Filter-name> <Filter-class>Com.baidu.ueditor.filter.UEditorFilter</Filter-class> </Filter> <filter-mapping> <Filter-name>Strutspreparefilter</Filter-name> <Url-pattern>/*</Url-pattern> </filter-mapping>
After configuring the Rich text Editor, you can use the
4. Examples of Use
<HTML><Head> <title>My JSP ' ueditordemo.jsp ' starting page</title> <Metahttp-equiv= "Pragma"content= "No-cache"> <Metahttp-equiv= "Cache-control"content= "No-cache"> <Metahttp-equiv= "Expires"content= "0"> <Metahttp-equiv= "keywords"content= "Keyword1,keyword2,keyword3"> <Metahttp-equiv= "description"content= "This is my page"> <Scripttype= "Text/javascript"CharSet= "Utf-8"src= "/bss/js/ueditor/ueditor.config.js"></Script> <Scripttype= "Text/javascript"CharSet= "Utf-8"src= "/bss/js/ueditor/ueditor.all.min.js"> </Script> <!--It is recommended to manually add the language, to avoid under IE sometimes because the load language failure causes the editor to fail to load - <!--the language file loaded here will overwrite the language type you added in the configuration item, such as the English you configured in the configuration item, the Chinese is loaded here, and the last is Chinese . - <Scripttype= "Text/javascript"CharSet= "Utf-8"src= "/bss/js/ueditor/lang/zh-cn/zh-cn.js"></Script> <!--<link rel= "stylesheet" type= "Text/css " href= "Styles.css" > -</Head> <Body> <ScriptID= "Editor"type= "Text/plain"style= "width:1024px;height:500px;"></Script> <Scripttype= "Text/javascript"> //Instantiation Editor varUE=Ue.geteditor ('Editor'); </Script></Body></HTML>
5. Custom return information
In the Com.baidu.ueditor.define.AppInfo.java
Public Static Final int Full_disk = 801; // disk space is full put (Appinfo.full_disk, "\u8d85\u51fa\u78c1\u76d8\u7a7a\u95f4\u989d\u5ea6\uff0c\u4e0d\u5141\u8bb8 \u4e0a\u4f20\u3002 ");
When used:
// disk space is full, return information return New Basestate (false, appinfo.full_disk);
6. Custom Configuration Properties and read
In Config.json Custom properties
/**/false,
Reading the configuration in Com.baidu.ueditor.ConfigManager.java
public map<string, object> getconfig ( int type) {Map <string, object> conf = new hashmap<string, objec T> (); String Savepath = null ; Conf.put ( "Savepath" , Savepath); Conf.put ( "RootPath", this .rootpath); Conf.put ( "Userconfigpath", this . Jsonconfig.getboolean (" Userconfigpath ")); // add by xxx return conf; }
7. custom file storage Path
The file store path can be modified in the configuration file, or you can customize
Com.baidu.ueditor.upload.BinaryUploader.java
Savepath = Pathformat.parse (Savepath, originfilename); // return to the picture URL in the page
= (String) conf.get ("RootPath") + Savepath; // physical path to picture storage
Modify the values of these two items according to your needs and you can complete the customization.
ueditor1_4_3-utf8-jsp configuration and customization, combined with STRUTS2