@Override protected AbstractUrlBasedView buildView(String viewName) throws Exception { MustacheView view = (MustacheView) super.buildView(viewName); view.setCompiler(this.compiler); view.setCharset(this.charset); return view; }
/** * 支持 jfinal enjoy、jsp、freemarker、velocity 四类模板共存于一个项目中 * * 注意:这里采用识别 ".jsp"、".ftl"、".vm" 模板后缀名的方式来实现功能 * 所以 jfinal enjoy 模板不要采用上述三种后缀名,否则功能将失效 * 还要注意与 jsp、freemarker、velocity 以外类型模板共存使用时 * 需要改造该方法 */ protected View loadView(String viewName, Locale locale) throws Exception { String suffix = getSuffix(); if (".jsp".equals(suffix) || ".ftl".equals(suffix) || ".vm".equals(suffix)) { return null; } else { return super.loadView(viewName, locale); } }
/** * spring 回调,利用 ServletContext 做必要的初始化工作 */ @Override protected void initServletContext(ServletContext servletContext) { super.initServletContext(servletContext); super.setExposeRequestAttributes(true); initBaseTemplatePath(servletContext); initSharedFunction(); }
/** * Apply the given properties to a {@link AbstractTemplateViewResolver}. Use Object in * signature to avoid runtime dependency on MVC, which means that the template engine * can be used in a non-web application. * * @param viewResolver the resolver to apply the properties to. */ protected void doApplyToViewResolver(Object viewResolver) { Assert.isInstanceOf(AbstractTemplateViewResolver.class, viewResolver, "ViewResolver is not an instance of AbstractTemplateViewResolver :" + viewResolver); AbstractTemplateViewResolver resolver = (AbstractTemplateViewResolver) viewResolver; resolver.setPrefix(getPrefix()); resolver.setSuffix(getSuffix()); resolver.setCache(isCache()); if (getContentType() != null) { resolver.setContentType(getContentType().toString()); } resolver.setViewNames(getViewNames()); resolver.setExposeRequestAttributes(isExposeRequestAttributes()); resolver.setAllowRequestOverride(isAllowRequestOverride()); resolver.setAllowSessionOverride(isAllowSessionOverride()); resolver.setExposeSessionAttributes(isExposeSessionAttributes()); resolver.setExposeSpringMacroHelpers(isExposeSpringMacroHelpers()); resolver.setRequestContextAttribute(getRequestContextAttribute()); // The resolver usually acts as a fallback resolver (e.g. like a // InternalResourceViewResolver) so it needs to have low precedence resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5); }
@Override protected void initApplicationContext() { super.initApplicationContext(); if (this.toolboxConfigLocation != null) { if (VelocityView.class == getViewClass()) { logger.info("Using VelocityToolboxView instead of default VelocityView " + "due to specified toolboxConfigLocation"); setViewClass(VelocityToolboxView.class); } else if (!VelocityToolboxView.class.isAssignableFrom(getViewClass())) { throw new IllegalArgumentException( "Given view class [" + getViewClass().getName() + "] is not of type [" + VelocityToolboxView.class.getName() + "], which it needs to be in case of a specified toolboxConfigLocation"); } } }
/** * Apply the given properties to a {@link AbstractTemplateViewResolver}. Use Object in * signature to avoid runtime dependency on MVC, which means that the template engine * can be used in a non-web application. * * @param viewResolver the resolver to apply the properties to. */ protected void doApplyToViewResolver(Object viewResolver) { Assert.isInstanceOf(AbstractTemplateViewResolver.class, viewResolver, "ViewResolver is not an instance of AbstractTemplateViewResolver :" + viewResolver); AbstractTemplateViewResolver resolver = (AbstractTemplateViewResolver) viewResolver; resolver.setPrefix(getPrefix()); resolver.setSuffix(getSuffix()); resolver.setCache(isCache()); if (getContentType() != null) { resolver.setContentType(getContentType().toString()); } resolver.setViewNames(getViewNames()); resolver.setExposeRequestAttributes(isExposeRequestAttributes()); resolver.setAllowRequestOverride(isAllowRequestOverride()); resolver.setAllowSessionOverride(isAllowSessionOverride()); resolver.setExposeSessionAttributes(isExposeSessionAttributes()); resolver.setExposeSpringMacroHelpers(isExposeSpringMacroHelpers()); resolver.setRequestContextAttribute(getRequestContextAttribute()); // The resolver usually acts as a fallback resolver (e.g. like a // InternalResourceViewResolver) so it needs to have low precedence resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5); }
@Override protected void initApplicationContext() { super.initApplicationContext(); if (this.toolboxConfigLocation != null) { if (VelocityView.class == getViewClass()) { logger.info("Using VelocityToolboxView instead of default VelocityView " + "due to specified toolboxConfigLocation"); setViewClass(VelocityToolboxView.class); } else if (!VelocityToolboxView.class.isAssignableFrom(getViewClass())) { throw new IllegalArgumentException( "Given view class [" + getViewClass().getName() + "] is not of type [" + VelocityToolboxView.class.getName() + "], which it needs to be in case of a specified toolboxConfigLocation"); } } }
@Override protected AbstractUrlBasedView buildView(String viewName) throws Exception { PebbleView view = (PebbleView) super.buildView(viewName); view.setTemplateName(viewName); view.setPebbleEngine(this.pebbleEngine); view.setCharacterEncoding(this.characterEncoding); return view; }
/** * spring 回调,利用 ServletContext 做必要的初始化工作 */ @Override protected void initServletContext(ServletContext servletContext) { super.initServletContext(servletContext); super.setExposeRequestAttributes(true); initBaseTemplatePath(servletContext); initSharedFunction(); }
/** * 支持 jfinal enjoy、jsp、freemarker、velocity 四类模板共存于一个项目中 * * 注意:这里采用识别 ".jsp"、".ftl"、".vm" 模板后缀名的方式来实现功能 * 所以 jfinal enjoy 模板不要采用上述三种后缀名,否则功能将失效 * 还要注意与 jsp、freemarker、velocity 以外类型模板共存使用时 * 需要改造该方法 */ protected View loadView(String viewName, Locale locale) throws Exception { String suffix = getSuffix(); if (".jsp".equals(suffix) || ".ftl".equals(suffix) || ".vm".equals(suffix)) { return null; } else { return super.loadView(viewName, locale); } }
@Override protected void initApplicationContext() { super.initApplicationContext(); if (this.toolboxConfigLocation != null) { if (VelocityView.class == getViewClass()) { logger.info("Using VelocityToolboxView instead of default VelocityView " + "due to specified toolboxConfigLocation"); setViewClass(VelocityToolboxView.class); } else if (!VelocityToolboxView.class.isAssignableFrom(getViewClass())) { throw new IllegalArgumentException( "Given view class [" + getViewClass().getName() + "] is not of type [" + VelocityToolboxView.class.getName() + "], which it needs to be in case of a specified toolboxConfigLocation"); } } }
@Override protected AbstractUrlBasedView buildView(String viewName) throws Exception { PebbleView view = (PebbleView) super.buildView(viewName); view.setTemplateName(viewName); view.setPebbleEngine(this.pebbleEngine); view.setCharacterEncoding(this.characterEncoding); return view; }
/** * spring 回调,利用 ServletContext 做必要的初始化工作 */ @Override protected void initServletContext(ServletContext servletContext) { super.initServletContext(servletContext); super.setExposeRequestAttributes(true); initBaseTemplatePath(servletContext); initSharedFunction(); }
/** * 支持 jfinal enjoy、jsp、freemarker、velocity 四类模板共存于一个项目中 * * 注意:这里采用识别 ".jsp"、".ftl"、".vm" 模板后缀名的方式来实现功能 * 所以 jfinal enjoy 模板不要采用上述三种后缀名,否则功能将失效 * 还要注意与 jsp、freemarker、velocity 以外类型模板共存使用时 * 需要改造该方法 */ protected View loadView(String viewName, Locale locale) throws Exception { String suffix = getSuffix(); if (".jsp".equals(suffix) || ".ftl".equals(suffix) || ".vm".equals(suffix)) { return null; } else { return super.loadView(viewName, locale); } }
@Override protected AbstractUrlBasedView buildView(String viewName) throws Exception { PebbleView view = (PebbleView) super.buildView(viewName); view.setTemplateName(viewName); view.setPebbleEngine(this.pebbleEngine); view.setCharacterEncoding(this.characterEncoding); return view; }
@Override protected View loadView(String viewName, Locale locale) throws Exception { View view = super.loadView(viewName, locale); if (view instanceof JetTemplateView) { ((JetTemplateView) view).setAllowRequestOverride(false); ((JetTemplateView) view).setAllowSessionOverride(false); } return view; }
@Override protected AbstractUrlBasedView buildView(String viewName) throws Exception { VelocityView view = (VelocityView) super.buildView(viewName); return view; }
@Override protected View loadView(String viewName, Locale locale) throws Exception { View view = super.loadView(viewName, locale); if (view instanceof JetTemplateView) { ((JetTemplateView) view).setAllowRequestOverride(false); ((JetTemplateView) view).setAllowSessionOverride(false); } return view; }
/** * {@inheritDoc} */ @Override protected AbstractUrlBasedView buildView(final String viewName) throws Exception { return configure((HandlebarsView) super.buildView(viewName)); }
@Override protected AbstractUrlBasedView buildView(String viewName) throws Exception { if (S.blank(viewName)) { return RythmView.EMPTY_VIEW; } else { return super.buildView(viewName); } } }