Recent project requirements need to use a text editor, before the use of fckeditor, found in IE incompatible, and there are more loopholes, decisively give up FCK, to invest in domestic Baidu embrace. Baidu's ueditor is still relatively powerful music, video, code patterns have.
First of all, streamlining
My project doesn't really need that much of a cool feature, just a simple text edit, so simplify it:
This is the file under dialogs.
Next
There are some CSS files, all left the default on the line is almost OK, after the deletion seems to have 4 points more than trillion, and so on after the time to try.
Image upload
But if you're using the Struts framework, STRUTS2 will intercept all the paths, so you need to customize an interceptor to prevent struts2 from uploading images or files to the editor, so you can customize the Interceptor, Because it is uploaded to the controller.jsp, so to let the path has controller's pass
public void DoFilter (ServletRequest req, servletresponse res,filterchain chain) throws IOException, Servletexception { HttpServletRequest request = (httpservletrequest) req; HttpServletResponse response = (httpservletresponse) res; HttpSession session = Request.getsession (); String Url=request.getservletpath (); String Contextpath=request.getcontextpath (); if (Url.equals ("")) url+= "/"; if ((Url.startswith ("/") &&url.startswith ("/fckeditor") | | Url.startswith ("/verifycodeservlet") | | Url.contains ("/controller")) { /*user user = (user) Session.getattribute ("Backuser"); if (user==null) {//Transfer to admin login page response.sendredirect (contextpath+ "/homeaction_backstage"); return; } * /Chain.dofilter (req, res); } else {super.dofilter (req, res, chain);}}
Then change the URL inside the ueditor.config.js.
Window. Ueditor_home_url = "/shareresource/ueditor1/";//change this to your own project path var URL = window. Ueditor_home_url | | Getuebasepath (); /** * Configuration item body. Note that all configuration involving paths here does not omit the URL variable. */ window. Ueditor_config = { //Add a path to the editor instance, this cannot be commented Ueditor_home_url:url //server Unified Request Interface Path , Serverurl:url + "jsp /controller.jsp "
In the Config.json file, this changes the URL
"Imageactionname": "Uploadimage",/* Perform the action name of the upload picture * /"Imagefieldname": "Upfile",/* submitted picture form name */ " Imagemaxsize ": 2048000,/* Upload size limit, Unit B * /" imageallowfiles ": [". png ",". jpg ",". jpeg ",". gif ",". bmp "],/* Upload picture format display */< c3/> "imagecompressenable": true,/* whether to compress the picture, the default is true * /"Imagecompressborder": 1600,/* picture compression longest edge limit */ " Imageinsertalign ":" None ",/* Insert Picture Floating way * /" Imageurlprefix ":"/shareresource ",/* Picture access Path prefix */ " Imagepathformat ":"/ueditor1/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6} ",/* Upload save path, can customize save path and file name format */ * * {filename} will be replaced with the original file name, configure this need to pay attention to the Chinese garbled problem * *
Upload a picture on it.
Then initialize on the page:
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%><%@ taglib prefix= "s" uri= "/struts-tags" %><%string path = Request.getcontextpath (); String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
End.
Ueditor streamline and implement upload image files, etc.