1,首先下载ueditor1_4_3-utf8-jsp并解压,下载地址:http://ueditor.baidu.com/website/download.html
2,在eclipse里新建一个 Dynamic web项目(我新建的项目为UeditorDemo),建好项目后,会有一个WebContent文件夹,在此目录下新建文件夹ueditor1_4_3,
然后把解压的ueditor1_4_3-utf8-jsp目录下的所有文件都复制到新建文件夹ueditor1_4_3下
如下图所示:
3,在index.jsp中配置引用ueditor:
4,把ueditor1_4_3-utf8-jsp\jsp\lib下的jar包复制到WebContent/WEB-INF/lib下,如下图:
5
,打开ueditor1_4_3/jsp/config.json文件:修改图片访问路径前缀imageUrlPrefix的值为符合项目访问的值,如下图:
6,修改ueditor1_4_3/ueditor.config.js的window.UEDITOR_HOME_URL为符合项目访问的路径,如下图:
在ueditor1_4_3/ueditor.config.js中也可修改编辑器的大小,如下图:
7,在tomcat中启动项目后,输入地址http://localhost:8080/UeditorDemo/index.jsp就会出现编辑器,选择图片上传按钮即可上传图片,
如下图所示:
转载:http://blog.sina.com.cn/s/blog_8d960c4c0102v468.html
配置完毕之后用于ssh框架中时,会报错“
未找到上传数据
”
此时需要自定过滤器
新建一个过滤器的类,代码:
- 1 package com.filter;
- 2
- 3 import java.io.IOException;
- 4
- 5 import javax.servlet.FilterChain;
- 6 import javax.servlet.ServletException;
- 7 import javax.servlet.ServletRequest;
- 8 import javax.servlet.ServletResponse;
- 9 import javax.servlet.http.HttpServletRequest;
- 10
- 11 import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;
- 12
- 13 public class EditorStrutsFilter extends StrutsPrepareAndExecuteFilter{
- 14 public void doFilter(ServletRequest req, ServletResponse res,
- 15 FilterChain chain) throws IOException, ServletException {
- 16 HttpServletRequest request = (HttpServletRequest) req;
- 17 String url = request.getRequestURI();
- 18 System.out.println(url);
- 19 if (url.contains("/jsp/")) {
- 20 System.out.println("使用自定义过滤器");
- 21 chain.doFilter(req, res);
- 22 }else{
- 23 System.out.println("使用默认过滤器");
- 24 super.doFilter(req, res, chain);
- 25 }
- 26 }
复制代码
之后在web.xml里面配置struts2过滤器
- 1 <filter>
- 2 <filter-name>struts2</filter-name>
- 3 <filter-class>com.filter.EditorStrutsFilter</filter-class>
- 4 </filter>
- 5 <filter-mapping>
- 6 <filter-name>struts2</filter-name>
- 7 <url-pattern>/*</url-pattern>
- 8 </filter-mapping>
复制代码
注意,如果有
- 1 <filter>
- 2 <filter-name>struts2</filter-name>
- 3 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
- 4 </filter>
复制代码
要将其删除
最后,希望大家转载请注明出处,尊重别人的劳动成果http://my.oschina.net/jiangli0502/blog/210263
|