Convenience constructors for common view prefix/suffix scenarios
Issue: SPR-13813
This commit is contained in:
@@ -66,6 +66,19 @@ public class InternalResourceViewResolver extends UrlBasedViewResolver {
|
||||
setViewClass(viewClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This resolver requires {@link InternalResourceView}.
|
||||
|
||||
@@ -40,10 +40,28 @@ import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
|
||||
*/
|
||||
public class FreeMarkerViewResolver extends AbstractTemplateViewResolver {
|
||||
|
||||
/**
|
||||
* Sets the default {@link #setViewClass view class} to {@link #requiredViewClass}:
|
||||
* by default {@link FreeMarkerView}.
|
||||
*/
|
||||
public FreeMarkerViewResolver() {
|
||||
setViewClass(requiredViewClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 FreeMarkerViewResolver(String prefix, String suffix) {
|
||||
this();
|
||||
setPrefix(prefix);
|
||||
setSuffix(suffix);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Requires {@link FreeMarkerView}.
|
||||
*/
|
||||
|
||||
@@ -38,10 +38,28 @@ import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
|
||||
*/
|
||||
public class GroovyMarkupViewResolver extends AbstractTemplateViewResolver {
|
||||
|
||||
/**
|
||||
* Sets the default {@link #setViewClass view class} to {@link #requiredViewClass}:
|
||||
* by default {@link GroovyMarkupView}.
|
||||
*/
|
||||
public GroovyMarkupViewResolver() {
|
||||
setViewClass(requiredViewClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 GroovyMarkupViewResolver(String prefix, String suffix) {
|
||||
this();
|
||||
setPrefix(prefix);
|
||||
setSuffix(suffix);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<?> requiredViewClass() {
|
||||
return GroovyMarkupView.class;
|
||||
|
||||
@@ -35,10 +35,28 @@ import org.springframework.web.servlet.view.UrlBasedViewResolver;
|
||||
*/
|
||||
public class ScriptTemplateViewResolver extends UrlBasedViewResolver {
|
||||
|
||||
/**
|
||||
* Sets the default {@link #setViewClass view class} to {@link #requiredViewClass}:
|
||||
* by default {@link ScriptTemplateView}.
|
||||
*/
|
||||
public ScriptTemplateViewResolver() {
|
||||
setViewClass(requiredViewClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ScriptTemplateViewResolver(String prefix, String suffix) {
|
||||
this();
|
||||
setPrefix(prefix);
|
||||
setSuffix(suffix);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<?> requiredViewClass() {
|
||||
return ScriptTemplateView.class;
|
||||
|
||||
Reference in New Issue
Block a user