开发者社区> 问答> 正文

Ehcache 使用SimplePageCachingFilter进行页面缓存,中文出现乱码?

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

展开
收起
小旋风柴进 2016-03-03 17:56:35 3604 0
1 条回答
写回答
取消 提交回答
  • 通过加载net.sf.ehcache.constructs.web.GenericResponseWrapper类放到src下进行解决.

    2019-07-17 18:51:44
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
基于英特尔 SSD 的虚拟机缓存解决SSD 立即下载
用户态高速块缓存方案 立即下载
高性能Web架构之缓存体系 立即下载