页面的图片如果要求命名为中文时
解决方法1:
修改server.xml配置
加入URIEncoding=UTF-8
不过这种方法貌似不可行
解决方法2:使用过滤器
在WEB-INF/web.xml配置
urlFilter
com.guanhuodata.framework.core.UrlFilter
DEFAULT_URI_ENCODE
UTF-8
过滤器实现类
public class UrlFilter implements Filter {
public final static String DEFAULT_URI_ENCODE = "UTF-8";
private FilterConfig config = null;
private String encode = null;
public void init(FilterConfig config) throws ServletException
{
this.config = config;
this.encode = config.getInitParameter("DEFAULT_URI_ENCODE");
if (this.encode == null) {
this.encode = DEFAULT_URI_ENCODE;
}
}
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
String uri = request.getRequestURI();
String ch = URLDecoder.decode(uri, encode);
if (uri.equals(ch)) {
chain.doFilter(req, res);
return;
}
ch = ch.substring(request.getContextPath().length());
config.getServletContext().getRequestDispatcher(ch).forward(req,
res);
}
public void destroy() {
config = null;
}
}