/** * Exposes a JSTL LocalizationContext for Spring's locale and MessageSource. * @see JstlUtils#exposeLocalizationContext */ @Override protected void exposeHelpers(HttpServletRequest request) throws Exception { if (this.messageSource != null) { JstlUtils.exposeLocalizationContext(request, this.messageSource); } else { JstlUtils.exposeLocalizationContext(new RequestContext(request, getServletContext())); } }
@Test public void testBeanNameViewResolver() throws ServletException { StaticWebApplicationContext wac = new StaticWebApplicationContext(); wac.setServletContext(new MockServletContext()); MutablePropertyValues pvs1 = new MutablePropertyValues(); pvs1.addPropertyValue(new PropertyValue("url", "/example1.jsp")); wac.registerSingleton("example1", InternalResourceView.class, pvs1); MutablePropertyValues pvs2 = new MutablePropertyValues(); pvs2.addPropertyValue(new PropertyValue("url", "/example2.jsp")); wac.registerSingleton("example2", JstlView.class, pvs2); BeanNameViewResolver vr = new BeanNameViewResolver(); vr.setApplicationContext(wac); wac.refresh(); View view = vr.resolveViewName("example1", Locale.getDefault()); assertEquals("Correct view class", InternalResourceView.class, view.getClass()); assertEquals("Correct URL", "/example1.jsp", ((InternalResourceView) view).getUrl()); view = vr.resolveViewName("example2", Locale.getDefault()); assertEquals("Correct view class", JstlView.class, view.getClass()); assertEquals("Correct URL", "/example2.jsp", ((JstlView) view).getUrl()); }
private View getViewInternal(String viewPath, RequestContext context, ApplicationContext flowContext) { if (viewPath.endsWith(".jsp") || viewPath.endsWith(".jspx")) { if (JSTL_PRESENT) { JstlView view = new JstlView(viewPath); view.setApplicationContext(flowContext); return view; } else { InternalResourceView view = new InternalResourceView(viewPath); view.setApplicationContext(flowContext); return view; } } else { throw new IllegalArgumentException("Unsupported view type " + viewPath + " only types supported by this FlowViewResolver implementation are [.jsp] and [.jspx]"); } } }
@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(); } };
@Override protected void exposeHelpers(HttpServletRequest request) throws Exception { setServletContext(request.getServletContext()); super.exposeHelpers(request); request.setAttribute("teacher$actual$page", "/teacher/" + page + ".jsp"); }
@Override public void setUrl(String viewName){ super.setUrl(extractTemplateUrl(viewName)); this.originalViewName = viewName; }
super.render(model, request, response);
private View getViewInternal(String viewPath, RequestContext context, ApplicationContext flowContext) { if (viewPath.endsWith(".jsp") || viewPath.endsWith(".jspx")) { if (JSTL_PRESENT) { JstlView view = new JstlView(viewPath); view.setApplicationContext(flowContext); return view; } else { InternalResourceView view = new InternalResourceView(viewPath); view.setApplicationContext(flowContext); return view; } } else { throw new IllegalArgumentException("Unsupported view type " + viewPath + " only types supported by this FlowViewResolver implementation are [.jsp] and [.jspx]"); } } }
@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(); } };
@Override protected void exposeHelpers(HttpServletRequest request) throws Exception { Map<String, String> templateParameters = extractTemplateParameters(originalViewName); if (templateParameters != null){ StdrUtil.getParameters(request).putAll(templateParameters); } super.exposeHelpers(request); }
private View getViewInternal(String viewPath, RequestContext context, ApplicationContext flowContext) { if (viewPath.endsWith(".jsp") || viewPath.endsWith(".jspx")) { if (JSTL_PRESENT) { JstlView view = new JstlView(viewPath); view.setApplicationContext(flowContext); return view; } else { InternalResourceView view = new InternalResourceView(viewPath); view.setApplicationContext(flowContext); return view; } } else { throw new IllegalArgumentException("Unsupported view type " + viewPath + " only types supported by this FlowViewResolver implementation are [.jsp] and [.jspx]"); } } }
/** * Exposes a JSTL LocalizationContext for Spring's locale and MessageSource. * @see JstlUtils#exposeLocalizationContext */ @Override protected void exposeHelpers(HttpServletRequest request) throws Exception { if (this.messageSource != null) { JstlUtils.exposeLocalizationContext(request, this.messageSource); } else { JstlUtils.exposeLocalizationContext(new RequestContext(request, getServletContext())); } }
/** * Exposes a JSTL LocalizationContext for Spring's locale and MessageSource. * @see JstlUtils#exposeLocalizationContext */ @Override protected void exposeHelpers(HttpServletRequest request) throws Exception { if (this.messageSource != null) { JstlUtils.exposeLocalizationContext(request, this.messageSource); } else { JstlUtils.exposeLocalizationContext(new RequestContext(request, getServletContext())); } }