本文共 3347 字,大约阅读时间需要 11 分钟。
1.下载UEditor【1.4.3 JSP版本】.下载地址:
解压之后的文件的目录是这样的:
打开eclipse,file->NEW->Other->Web->Dynamic Web Project->next. Project name自定义,Dynamic web module version选择 2.5.Finish。
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>news.jsp完整demo
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>7.编辑新闻:news <% request.setCharacterEncoding("utf-8"); String newsbody = request.getParameter("editorValue"); %><%=newsbody%>
3.config.json文件中有提交的图片图片表单名称设置, “ "imageFieldName": "upfile", /* 提交的图片表单名称 */”,上传图片的表单属性中加入一行name="upfile",测试:
package com.test.filter;import java.io.IOException;import javax.servlet.FilterChain;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import javax.servlet.http.HttpServletRequest;import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;public class MyStrutsFilter extends StrutsPrepareAndExecuteFilter{ public void doFilter(ServletRequest req, ServletResponse res,FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; //不过滤的url String url = request.getRequestURI(); System.out.println(url); if ("/uetest/ueditor1_4_3/jsp/controller.jsp".equals(url)) { //注意路径 System.out.println("使用自定义的过滤器"); chain.doFilter(req, res); }else{ System.out.println("使用默认的过滤器"); super.doFilter(req, res, chain); } } }
struts2 com.test.filter.MyStrutsFilter struts2 /*