环境描述:java+struts2
问题描述:上传图片出错,显示小叉号
问题原因及解决:struts封装了request,所以这里要让struts过滤掉这个jsp页面的部分信息。
我加了一个Filter类
public class MyStrutsFilter extends StrutsPrepareAndExecuteFilter {
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException,
ServletException {
HttpServletRequest request = (HttpServletRequest) req;
//不过滤上传图片的URL
String url = request.getRequestURI();
if ("/FruitAdm/ueditor/jsp/imageUp.jsp".equals(url)) {
chain.doFilter(req, res);
} else {
super.doFilter(req, res, chain);
}
}
}
<filter> <filter-name>struts2</filter-name> <filter-class>cn.aytech.produceadm.util.MyStrutsFilter</filter-class> </filter>
原文:http://blog.csdn.net/jasper_success/article/details/22497653