Java 类org.springframework.web.servlet.view.AbstractTemplateView 实例源码

项目:easycode    文件:GlobalController.java   
@RequestMapping("/decorator")
public void decorator(HttpServletRequest request, HttpServletResponse response) throws Exception {
    AbstractTemplateView view = (AbstractTemplateView)viewResolver.resolveViewName("decorator", 
            localeResolver.resolveLocale(request));
    //因为此请求是Sitemesh forward进来的,如果不做下面两个Override配置的话会重复设置Model,而Spring MVC碰到重复参数名会抛异常
    //详细逻辑请阅读 {@link AbstractTemplateView} 的 renderMergedOutputModel方法

    //启用spring.freemarker.expose-request-attributes=true时则需要启用下面的代码
    //view.setAllowRequestOverride(true);

    //启用spring.freemarker.expose-session-attributes=true时则需要启用下面的代码
    //view.setAllowSessionOverride(true);

    view.setExposeSpringMacroHelpers(false);
    view.render(null, request, response);
}
项目:java-platform    文件:I18nFunction.java   
@Override
public Object call(Object[] paras, Context ctx) {

    RequestContext requestContext = (RequestContext) ctx
            .getGlobal(AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE);

    Assert.notNull(requestContext);
    Assert.notNull(paras);
    Assert.isTrue(paras.length > 0);

    String code = (String) paras[0];
    Object[] args = paras.length > 1 ? Arrays.copyOfRange(paras, 1, paras.length) : null;

    return requestContext.getMessage(code, args);
}
项目:thymeleaf-jawr-extension    文件:JawrDialectProcessingContextBuilder.java   
private void additionalVariableProcessing(ConversionService conversionService, Map<String, Object> variables) {
    RequestContext requestContext = (RequestContext) variables.get(AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE);
    variables.put(SpringContextVariableNames.SPRING_REQUEST_CONTEXT, requestContext);

    ThymeleafEvaluationContext evaluationContext = new ThymeleafEvaluationContext(applicationContext, conversionService);

    variables.put(ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, evaluationContext);
}
项目:mev    文件:AbstractTemplateViewBuilder.java   
protected <V extends AbstractTemplateView> V initialize (V view) {
  super.initialize (view);
  view.setAllowRequestOverride (allowRequestOverride);
  view.setAllowSessionOverride (allowSessionOverride);
  view.setExposeRequestAttributes (exposeRequestAttributes);
  view.setExposeSessionAttributes (exposeSessionAttributes);
  view.setExposeSpringMacroHelpers (exposeSpringMacroHelpers);
  return view;
}
项目:thymeleaf-jawr-extension    文件:JawrDialectProcessingContextBuilder.java   
private void doAdditionalVariableProcessing(ITest test, Locale locale, Map<String, Object> variables) {
    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext);

    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext);

    RequestContextHolder.setRequestAttributes(webRequest);

    ConversionService conversionService = getConversionService();

    RequestContext requestContext = new RequestContext(request, response, servletContext, variables);
    variables.put(AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE, requestContext);

    additionalVariableProcessing(conversionService, variables);

    initializeBindingResults(test, conversionService, locale, variables);

    injectJawrProperties(test);
}