<script type="text/javascript" src="script/ueditor/ueditor.config.js" charset="utf-8"></script>
<script type="text/javascript" src="script/ueditor/ueditor.all.js" charset="utf-8"></script>
<script type="text/javascript" src="script/ueditor/ueditor.all.min.js" charset="utf-8"></script> 处理乱码
var editor=UE.getEditor('desc',{
});
var editor=UE.getEditor('desc',{
initialFrameWidth:500,
initialFrameHeight:100,
autoHeightEnabled:false,
toolbars:[['fullscreen', 'source', '|', 'undo', 'redo','|','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|','fontfamily', 'fontsize','forecolor', 'backcolor', '|', 'insertimage','imageleft','imageright', 'imagecenter']]
});
function tijiao(){
editor.sync();
document.f.submit();
}
2011-7-30 20:29:02 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info 信息: Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir
原因是没有设置存放临时文件的文件夹,而错误提示中的struts.multipart.saveDir就是设置临时文件夹的属性,把该配置写到struts.properties文件中即可,如下:
struts.multipart.saveDir = /tmp
如果此文件夹不存在,Struts 2会自动创建一个。
也可以在struts.xml配置文件中添加一个常量设置:(推荐用这种方法)
<constant name="struts.multipart.saveDir" value="/tmp"></constant>
1. jsp中有个ueditor.jar 要把它移到 tomcat中 (bulid path),否则报 class 找不到问题 。。
2. 文件上传问题 ,如何你使用了 struts ,文件上传imageup.jsp 会被struts拦截 ,无法上传成功,所以要自定义拦截器 ,排除这个url 其他的仍然拦截
拦截器把(/*)所有请求的文件都做了处理,所以导致无法上传图片。
解决方法,自定义拦截器,让它在请求imageUp.jsp文件时不做处理。
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 ("/yourWebName/ueditor/server/upload/jsp/imageUp.jsp".equals(url)) { System.out.println("使用自定义的过滤器"); chain.doFilter(req, res); }else{ System.out.println("使用默认的过滤器"); super.doFilter(req, res, chain); } } }
把默认拦截器改为以下拦截器
<filter> <filter-name>struts2</filter-name> <filter-class> com.lijia.MyStrutsFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
3.servlet+jsp环境
步骤:
A、修改ueditor/dialogs/image/image.html,找到url
改成'../../server/upload/jsp/imageUp.jsp', 注意路径
B、修改ueditor/editor_config,找到URL改成'/yourWebName/ueditor/',
imagePath改成"/yourWebName/"