您现在的位置:首页 >> 前端 >> 内容

WEB项目中使用UEditor(富文本编辑器)

时间:2017/5/5 17:02:00 点击:

  核心提示:WEB项目中使用UEditor(富文本编辑器)。Ueditor富文本编辑器是在很多项目里经常用到的框架,是百度开发团队开发的一款很好用的富文本编辑器。下面就是我在一个系统里用到的,有了富文本编辑器,管...

WEB项目中使用UEditor(富文本编辑器)。Ueditor富文本编辑器是在很多项目里经常用到的框架,是百度开发团队开发的一款很好用的富文本编辑器。

下面就是我在一个系统里用到的,有了富文本编辑器,管理员使用起来不是很方便?

所以本博客介绍这个富文本编辑器的使用哈!觉得写得不错的请点赞哈,有建议欢迎提哈!^V^

WEB项目中使用UEditor(富文本编辑器)

下载链接:https://ueditor.baidu.com/website/download.html

具体的使用请看官网:https://ueditor.baidu.com/website/index.html

下载富文本编辑器后,我们打开MyEclipse或者其它编辑软件,选择file->import,选择文件系统,导入下载好的Ueditor

WEB项目中使用UEditor(富文本编辑器)

然后启动tomcat服务器

https://localhost:8080/项目名称t/ueditor1_4_3_2/jsp/controller.jsp?action=config

这个要根据你的项目进行修改的哈

可以输出这个,什么编辑器导入成功

WEB项目中使用UEditor(富文本编辑器)

引入js,charset属性设置为UTF-8的,因为我的系统默认是UTF-8的

复制ueditor里面的index,html代码,这个要根据需要去复制的

因为我做的系统只要实现将编辑的文本和样式一起写入数据库,所以只要使用getContext方法就可以

在form表单里加入:

获取文本和文本样式的参考代码,

String introduction = new String(request.getParameter("editorValue").getBytes("iso-8859-1"),"UTF-8");

这个就是获取文本和文本样式的代码,然后下面的代码只是参考的,只要用String introduction = new String(request.getParameter("editorValue").getBytes("iso-8859-1"),"UTF-8");

这代码就可以获取内容

publicclassAddSpotInfoServletextendsHttpServlet{

/**

*

*/

privatestaticfinallongserialVersionUID=1L;

/**

*

*/

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

response.setContentType("text/html;charset=UTF-8");

PrintWriterout=response.getWriter();

request.setCharacterEncoding("UTF-8");

Stringintroduction=newString(request.getParameter("editorValue").getBytes("iso-8859-1"),"UTF-8");

Stringpicture=Constant.ImgPath.path;

Stringposition=newString(request.getParameter("position").getBytes("iso-8859-1"),"UTF-8");

StringpriceString=newString(request.getParameter("price").getBytes("iso-8859-1"),"UTF-8");

Doubleprice=Double.parseDouble(priceString);

StringsortString=newString(request.getParameter("sort").getBytes("iso-8859-1"),"UTF-8");

intspot_sort=Integer.parseInt(sortString);

//StringtimeString=newString(request.getParameter("time").getBytes("iso-8859-1"),"UTF-8");

//Datetime=Date.valueOf(timeString);

Stringtour_project=newString(request.getParameter("tour_project").getBytes("iso-8859-1"),"UTF-8");

Spotspot=newSpot();

spot.setIntroduction(introduction);

spot.setPicture(picture);

spot.setPosition(position);

spot.setPrice(price);

spot.setSpot_sort(spot_sort);

spot.setTour_project(tour_project);

SpotDAOspotDao=newSpotDAOImpl();

booleanflag=spotDao.addInfo(spot);

if(flag){

response.sendRedirect(Constant.WEB_URL_SPOT_SERVLET);

}

out.flush();

out.close();

}

/**

*

*/

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

doGet(request,response);

}

}

ok,可以将文本和样式一起写入数据库了,哈哈哈,^V^

WEB项目中使用UEditor(富文本编辑器)

Ueditor富文本编辑器是在很多项目里经常用到的框架,是百度开发团队开发的一款很好用的富文本编辑器

下面就是我在一个系统里用到的,有了富文本编辑器,管理员使用起来不是很方便?

所以本博客介绍这个富文本编辑器的使用哈!觉得写得不错的请点赞哈,有建议欢迎提哈!^V^

WEB项目中使用UEditor(富文本编辑器)

下载链接:https://ueditor.baidu.com/website/download.html

具体的使用请看官网:https://ueditor.baidu.com/website/index.html

下载富文本编辑器后,我们打开MyEclipse或者其它编辑软件,选择file->import,选择文件系统,导入下载好的Ueditor

WEB项目中使用UEditor(富文本编辑器)

然后启动tomcat服务器

https://localhost:8080/项目名称t/ueditor1_4_3_2/jsp/controller.jsp?action=config

这个要根据你的项目进行修改的哈

可以输出这个,什么编辑器导入成功

WEB项目中使用UEditor(富文本编辑器)

引入js,charset属性设置为UTF-8的,因为我的系统默认是UTF-8的

复制ueditor里面的index,html代码,这个要根据需要去复制的

因为我做的系统只要实现将编辑的文本和样式一起写入数据库,所以只要使用getContext方法就可以

在form表单里加入:

注意这些属性都不用随便修改的哦

获取文本和文本样式的参考代码,

String introduction = new String(request.getParameter("editorValue").getBytes("iso-8859-1"),"UTF-8");

这个就是获取文本和文本样式的代码,然后下面的代码只是参考的,只要用String introduction = new String(request.getParameter("editorValue").getBytes("iso-8859-1"),"UTF-8");

这代码就可以获取内容

publicclassAddSpotInfoServletextendsHttpServlet{

/**

*

*/

privatestaticfinallongserialVersionUID=1L;

/**

*

*/

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

response.setContentType("text/html;charset=UTF-8");

PrintWriterout=response.getWriter();

request.setCharacterEncoding("UTF-8");

Stringintroduction=newString(request.getParameter("editorValue").getBytes("iso-8859-1"),"UTF-8");

Stringpicture=Constant.ImgPath.path;

Stringposition=newString(request.getParameter("position").getBytes("iso-8859-1"),"UTF-8");

StringpriceString=newString(request.getParameter("price").getBytes("iso-8859-1"),"UTF-8");

Doubleprice=Double.parseDouble(priceString);

StringsortString=newString(request.getParameter("sort").getBytes("iso-8859-1"),"UTF-8");

intspot_sort=Integer.parseInt(sortString);

//StringtimeString=newString(request.getParameter("time").getBytes("iso-8859-1"),"UTF-8");

//Datetime=Date.valueOf(timeString);

Stringtour_project=newString(request.getParameter("tour_project").getBytes("iso-8859-1"),"UTF-8");

Spotspot=newSpot();

spot.setIntroduction(introduction);

spot.setPicture(picture);

spot.setPosition(position);

spot.setPrice(price);

spot.setSpot_sort(spot_sort);

spot.setTour_project(tour_project);

SpotDAOspotDao=newSpotDAOImpl();

booleanflag=spotDao.addInfo(spot);

if(flag){

response.sendRedirect(Constant.WEB_URL_SPOT_SERVLET);

}

out.flush();

out.close();

}

/**

*

*/

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

doGet(request,response);

}

}

ok,可以将文本和样式一起写入数据库了,哈哈哈,^V^

WEB项目中使用UEditor(富文本编辑器)

Tags:WE EB B项 项目 
作者:网络 来源:BillyLu的博客