01: /*
02: * Copyright 2002-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.web.servlet.view.freemarker;
18:
19: import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
20:
21: /**
22: * Convenience subclass of UrlBasedViewResolver that supports FreeMarkerView
23: * (i.e. FreeMarker templates) and custom subclasses of it.
24: *
25: * <p>The view class for all views generated by this resolver can be specified
26: * via <code>setViewClass</code>. See UrlBasedViewResolver's javadoc for details.
27: *
28: * <p><b>Note:</b> When chaining ViewResolvers, a FreeMarkerViewResolver always
29: * needs to be last, as it will attempt to resolve any view name, no matter
30: * whether the underlying resource actually exists.
31: *
32: * @author Juergen Hoeller
33: * @since 1.1
34: * @see #setViewClass
35: * @see #setPrefix
36: * @see #setSuffix
37: * @see #setRequestContextAttribute
38: * @see #setExposeSpringMacroHelpers
39: * @see FreeMarkerView
40: */
41: public class FreeMarkerViewResolver extends
42: AbstractTemplateViewResolver {
43:
44: /**
45: * Sets default viewClass to <code>requiredViewClass</code>.
46: * @see #setViewClass
47: * @see #requiredViewClass
48: */
49: public FreeMarkerViewResolver() {
50: setViewClass(requiredViewClass());
51: }
52:
53: /**
54: * Requires FreeMarkerView.
55: * @see FreeMarkerView
56: */
57: protected Class requiredViewClass() {
58: return FreeMarkerView.class;
59: }
60:
61: }
|