sitemesh2 集成velocity 装饰页面乱码

请参考:
http://www.cnblogs.com/andrewlee/p/3825653.html

通过改写类 VelocityView 的 getTemplate 方法
public Template getTemplate(String name, String encoding)
    {
        try
        {
            if (encoding == null)
            {
                return velocity.getTemplate(name,"UTF-8");
            }
            else
            {
                return velocity.getTemplate(name, encoding);
            }
        }
        catch (RuntimeException e)  // FIXME This is useless with Velocity 1.7
        {
            throw e;
        }
        catch (Exception e)  // FIXME This is useless with Velocity 1.7
        {
            throw new RuntimeException(e);
        }
    }


代码位置
http://svn.apache.org/viewvc/velocity/tools/tags/2.0/src/main/java/org/apache/velocity/tools/view/VelocityView.java?view=log

猜你喜欢

转载自javawxl.iteye.com/blog/2323096