@Override protected AbstractUrlBasedView buildView(String viewName) throws Exception { InternalResourceView view = (InternalResourceView) super.buildView(viewName); if (this.alwaysInclude != null) { view.setAlwaysInclude(this.alwaysInclude); } view.setPreventDispatchLoop(true); return view; }
@Override protected AbstractUrlBasedView buildView(String viewName) throws Exception { AbstractTemplateView view = (AbstractTemplateView) super.buildView(viewName); view.setExposeRequestAttributes(this.exposeRequestAttributes); view.setAllowRequestOverride(this.allowRequestOverride); view.setExposeSessionAttributes(this.exposeSessionAttributes); view.setAllowSessionOverride(this.allowSessionOverride); view.setExposeSpringMacroHelpers(this.exposeSpringMacroHelpers); return view; }
/** * A convenience constructor that allows for specifying {@link #setPrefix prefix} * and {@link #setSuffix suffix} as constructor arguments. * @param prefix the prefix that gets prepended to view names when building a URL * @param suffix the suffix that gets appended to view names when building a URL * @since 4.3 */ public InternalResourceViewResolver(String prefix, String suffix) { this(); setPrefix(prefix); setSuffix(suffix); }
/** * Sets the default {@link #setViewClass view class} to {@link #requiredViewClass}: * by default {@link InternalResourceView}, or {@link JstlView} if the JSTL API * is present. */ public InternalResourceViewResolver() { Class<?> viewClass = requiredViewClass(); if (InternalResourceView.class == viewClass && jstlPresent) { viewClass = JstlView.class; } setViewClass(viewClass); }
@Test public void testUrlBasedViewResolverWithoutPrefixes() throws Exception { UrlBasedViewResolver vr = new UrlBasedViewResolver(); vr.setViewClass(JstlView.class); doTestUrlBasedViewResolverWithoutPrefixes(vr); }
/** * Constructor for use as a bean. */ public RedirectView() { setExposePathVariables(false); }
/** * Set the prefix that gets prepended to view names when building a URL. * @see org.springframework.web.servlet.view.UrlBasedViewResolver#setPrefix */ public UrlBasedViewResolverRegistration prefix(String prefix) { this.viewResolver.setPrefix(prefix); return this; }
/** * Set the view class that should be used to create views. * @see org.springframework.web.servlet.view.UrlBasedViewResolver#setViewClass */ public UrlBasedViewResolverRegistration viewClass(Class<?> viewClass) { this.viewResolver.setViewClass(viewClass); return this; }
/** * Pre-initialize the factory from the XML file. * Only effective if caching is enabled. */ @Override public void afterPropertiesSet() throws BeansException { if (isCache()) { initFactory(); } }
/** * Whether to propagate the query parameters of the current request through * to the target redirect URL. * <p>Default is {@code false}. */ public RedirectViewControllerRegistration setKeepQueryParams(boolean propagate) { this.redirectView.setPropagateQueryParams(propagate); return this; }
@Override protected void initApplicationContext() { super.initApplicationContext(); if (getViewClass() == null) { throw new IllegalArgumentException("Property 'viewClass' is required"); } }
/** * Whether to interpret a given redirect URL that starts with a slash ("/") * as relative to the current ServletContext, i.e. as relative to the web * application root. * <p>Default is {@code true}. */ public RedirectViewControllerRegistration setContextRelative(boolean contextRelative) { this.redirectView.setContextRelative(contextRelative); return this; }
/** * Specify the maximum number of entries for the view cache. * Default is 1024. * @see org.springframework.web.servlet.view.UrlBasedViewResolver#setCache(boolean) */ public UrlBasedViewResolverRegistration cacheLimit(int cacheLimit) { this.viewResolver.setCacheLimit(cacheLimit); return this; }
/** * Eagerly initialize Locales if necessary. * @see #setLocalesToInitialize */ @Override public void afterPropertiesSet() throws BeansException { if (this.localesToInitialize != null) { for (Locale locale : this.localesToInitialize) { initFactory(locale); } } }
/** * Set static attributes to be added to the model of every request for all * views resolved by this view resolver. This allows for setting any kind of * attribute values, for example bean references. * @see org.springframework.web.servlet.view.UrlBasedViewResolver#setAttributesMap */ public UrlBasedViewResolverRegistration attributes(Map<String, ?> attributes) { this.viewResolver.setAttributesMap(attributes); return this; }
/** * Enable or disable caching. * <p>This is equivalent to setting the {@link #cacheLimit "cacheLimit"} * property to the default limit (1024) or to 0, respectively. * <p>Default is "true": caching is enabled. * Disable this only for debugging and development. * @see org.springframework.web.servlet.view.UrlBasedViewResolver#setCache(boolean) */ public UrlBasedViewResolverRegistration cache(boolean cache) { this.viewResolver.setCache(cache); return this; }
/** * @see org.springframework.web.servlet.support.RequestContext#getContextUrl(String) */ public String getContextUrl(String relativeUrl) { return getContextPath() + relativeUrl; }
/** * Create a new RedirectView with the given URL. * <p>The given URL will be considered as relative to the web server, * not as relative to the current ServletContext. * @param url the URL to redirect to * @see #RedirectView(String, boolean) */ public RedirectView(String url) { super(url); setExposePathVariables(false); }
/** * Create a new RedirectView with the given URL. * @param url the URL to redirect to * @param contextRelative whether to interpret the given URL as * relative to the current ServletContext */ public RedirectView(String url, boolean contextRelative) { super(url); this.contextRelative = contextRelative; setExposePathVariables(false); }