Using Ueditor (Rich Text editor) in Web projects

Source: Internet
Author: User


Ueditor Rich Text Editor is often used in many projects of the framework, Baidu Development team developed a very useful rich text editor


Here is what I used in a system, with a rich text editor, the administrator is not very convenient to use it?

So this blog introduces the use of this rich text editor ha! Feel good to write, please praise Ha, there are suggestions welcome to mention ha! ^v^



Download Link: http://ueditor.baidu.com/website/download.html

for specific use please crossing net: http://ueditor.baidu.com/website/index.html


After downloading the rich Text editor, we open MyEclipse or other editing software, select File->import, select File System, import the downloaded Ueditor

Then start the Tomcat server

http://localhost:8080/ project name t/ueditor1_4_3_2/jsp/controller.jsp?action=config

This is going to change according to your project, huh?

Can output this, what editor imported successfully


The introduction of the Js,charset property is set to UTF-8 because my system defaults to UTF-8

<span style= "FONT-SIZE:18PX;" ><script type= "Text/javascript" charset= "UTF-8" src= "<%=basepath%>ueditor1_4_3_2/ueditor.config.js" ></script>    <script type= "Text/javascript" charset= "UTF-8" src= "<%=basepath%>ueditor1_4_3_2/ Ueditor.all.min.js "> </script></span>


Copy the ueditor inside of the index,html code, this to be copied as needed

<span style= "FONT-SIZE:18PX;" ><script type= "Text/javascript" >    //Instantiation Editor    //recommend using the Factory method Geteditor Create and reference editor instances, if you reference the editor under a closure, Direct call to Ue.geteditor (' editor ') will be able to get relevant examples of    var UE = ue.geteditor (' editor ');      function GetContent () {        var arr = [];        Arr.push ("Use the Editor.getcontent () method to get the contents of the editor");        Arr.push ("content is:");        Arr.push (Ue.geteditor (' Editor '). getcontent ());        Alert (Arr.join ("\ n"));    }       </script></span>


Because I do the system as long as the implementation of the edited text and style to write to the database, so long as the use of the GetContext method can be


In the Form form, add:

<script id= "editor" type= "Text/plain" style= "width:1024px;height:500px;" ></script>


Notice that these properties don't have to be changed.


Get the reference code for text and text styles,


String introduction = new String (Request.getparameter ("Editorvalue"). GetBytes ("Iso-8859-1"), "UTF-8");
This is the code that gets the text and text style, and then the following code is just a reference, just use string introduction = new String (Request.getparameter ("Editorvalue"). GetBytes (" Iso-8859-1 ")," UTF-8 ");
This code will get the content


public class Addspotinfoservlet extends HttpServlet {/** * */private static final Long serialversionuid = 1l;/** * */pub LIC void doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException { Response.setcontenttype ("Text/html;charset=utf-8"); PrintWriter out = Response.getwriter (); Request.setcharacterencoding ("UTF-8"); String introduction = new String (Request.getparameter ("Editorvalue"). GetBytes ("Iso-8859-1"), "UTF-8"); String picture = Constant.ImgPath.path; String position = new String (Request.getparameter ("position"). GetBytes ("Iso-8859-1"), "UTF-8"); String pricestring = new String (Request.getparameter ("price"). GetBytes ("Iso-8859-1"), "UTF-8");D ouble price = Double.parsedouble (pricestring); String sortstring = new String (Request.getparameter ("Sort"). GetBytes ("Iso-8859-1"), "UTF-8"); int spot_sort = Integer.parseint (sortstring);//string timestring = new String (Request.getparameter ("Time"). GetBytes ("Iso-8859-1"), "UTF-8");//date time = date.valueof (timestring); String tour_project = new String (Request.getparameter ("Tour_project"). GetBytes ("Iso-8859-1"), "UTF-8"); Spot spot = new Spot (); Spot.setintroduction (introduction); Spot.setpicture (picture); spot.setposition (position); Spot.setprice (price); Spot.setspot_sort (Spot_sort); Spot.settour_project (Tour_project); Spotdao Spotdao = new Spotdaoimpl (), Boolean flag = Spotdao.addinfo (spot), if (flag) {Response.sendredirect (constant.web_ Url_spot_servlet);} Out.flush (); Out.close ();} /** * */public void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {doget (request, Response);}}

OK, text and style can be written to the database together, hahaha, ^v^







Using Ueditor (Rich Text editor) in Web projects

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.