Ueditor:
Http://ueditor.baidu.com/website/download.html
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8E/23/wKiom1i2gNPy4InwAABPEnaWuMg238.png-wh_500x0-wm_ 3-wmp_4-s_1507990240.png "title=" 1.png "alt=" Wkiom1i2gnpy4inwaabpenawumg238.png-wh_50 "/>
Unzip directly after download. I mainly implement file upload and form form submission data.
One, configuration file modification
Uedit.config.js
var URL = window. Ueditor_home_url; Mostly local ueditor files directory
Serverurl:url + "jsp/config.jhtml"//server Unified Request Interface Path
Conf.json
"Imageurlprefix": "http://localhost:8080/fetchbaike/ueditor/jsp/upload/",/* Image access Path prefix */
Second, the page modification
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8"/> <script type= "Text/javascript" charset= "Utf-8" src= "./ueditor/ueditor.config.js" > </script> <script type= "Text/javascript" charset= "Utf-8" src= ". /ueditor/ueditor.all.min.js "> </script> <!--recommended to be added manually in the language, Avoid in IE sometimes because the load language failure causes the editor to fail to load--> <!--the language files loaded here will overwrite the language type you added in the configuration item, such as the one you configured in the configuration item in English, The Chinese is loaded here, and the last is the Chinese--> <script type= "Text/javascript" charset= "Utf-8" src= "./ueditor/ Lang/zh-cn/zh-cn.js "></script>tyle type=" Text/css "> div{ width:100%; } </style>
Third, the background operation
@Controller @requestmapping (value= "/ueditor") public class ueditorcontroller {@RequestMapping ( Value= "/jsp/config") Public void config (httpservletrequest request,httpservletresponse Response,string action) throws Exception { Request.setcharacterencoding ("Utf-8"); response.setheader ("Content-type", "text/ HTML "); string rootpath=request.getsession (). Getservletcontext (). GetRealPath ("/"); //will load the Conf.json file, note the path Problem response.getwriter (). Write (new Actionenter (Request,rootpath). exec ()); @RequestMapping (value= "/uploadimage") @ResponseBodypublic map<string,object> uploadimage (@ Requestparam ("Upfile") multipartfile[] multipartfiles, httpservletrequest request, Httpservletresponse response) throws exception { map<string,Object> map=new hashmap<string,object> (); string path= Request.getsession (). Getservletcontext (). Getrealpath ("/ueditor/jsp/upload/"); System.out.println ("path++" +path); if (multipartfiles!=null && multipartfiles.length>0) { //loop traversal for (multipartfile multipartfile : multipartfiles) { //name of original picture String Originalfilename=multipartfile.getoriginalfilename (); //get picture new name &nbSp String newfilename=getfilenewname (Originalfilename.substring (Originalfilename.lastindexof ("."))); //Creating Files File targetfile=new file (Path,newfilename); if (!targetfile.exists ()) { targetfile.mkdirs (); } string state= " SUCCESS "; try { multipartfile.transferto ( TargetFile); &Nbsp; map.put ("original", OriginalFilename); map.put ("name", NewFileName); //Note The URL will match the path in Conf.json to find the image map.put ("url", newfilename); map.put ("state", "SUCCESS"); } catch (exception e) { state= "FAIL"; } } } return&nbSp;map;}
Using Ueditor in SPRINGMVC