Search in sources :

Example 1 with JstlView

use of org.springframework.web.servlet.view.JstlView in project leopard by tanhaichao.

the class FileCacheView method createView.

protected JstlView createView(String viewName) {
    return new JstlView("/WEB-INF/jsp/" + viewName + ".jsp") {

        @Override
        protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
            ServletOutputStream output = response.getOutputStream();
            ServletContext servletContext = request.getServletContext();
            super.setServletContext(servletContext);
            CacheResponseWrapper cacheResponseWrapper = new CacheResponseWrapper(response);
            // System.err.println("renderMergedOutputModel");
            super.renderMergedOutputModel(model, request, cacheResponseWrapper);
            byte[] data = cacheResponseWrapper.getResponseData();
            String content = new String(data);
            response(content);
            output.write(data);
            output.flush();
        }
    };
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletOutputStream(javax.servlet.ServletOutputStream) JstlView(org.springframework.web.servlet.view.JstlView) HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletContext(javax.servlet.ServletContext) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 ServletContext (javax.servlet.ServletContext)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 JstlView (org.springframework.web.servlet.view.JstlView)1