Ehcache 使用SimplePageCachingFilter进行页面缓存,中文出现乱码,未用之前是正常的。我增加了过滤器也不好用,见code:
/**
* The default character encoding to set for requests that pass through this
* filter.
* 字符集编码设置
*/
protected String encoding = null;
/* (non-Javadoc)
* @see net.sf.ehcache.constructs.web.filter.CachingFilter#doFilter(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain)
*/
@Override
public void doFilter(HttpServletRequest request,
HttpServletResponse response, FilterChain chain)
throws AlreadyGzippedException, AlreadyCommittedException,
FilterNonReentrantException, LockTimeoutException, Exception {
if (encoding != null)
{
request.setCharacterEncoding(encoding);
}
super.doFilter(request, response, chain);
}
/* (non-Javadoc)
* @see net.sf.ehcache.constructs.web.filter.CachingFilter#doInit(javax.servlet.FilterConfig)
*/
@Override
public void doInit(FilterConfig filterConfig) throws CacheException {
this.encoding = filterConfig.getInitParameter("encoding");
super.doInit(filterConfig);
}
使用环境:ubuntu14.04 ,weblogic 9.24,java 1.5,eclipse
通过加载net.sf.ehcache.constructs.web.GenericResponseWrapper类放到src下进行解决.
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。