41
41
import org .springframework .web .servlet .view .script .ScriptTemplateViewResolver ;
42
42
import org .springframework .web .servlet .view .tiles3 .TilesConfigurer ;
43
43
import org .springframework .web .servlet .view .tiles3 .TilesViewResolver ;
44
- import org .springframework .web .servlet .view .velocity .VelocityConfigurer ;
45
- import org .springframework .web .servlet .view .velocity .VelocityViewResolver ;
46
44
47
45
/**
48
46
* Assist with the configuration of a chain of
@@ -86,10 +84,8 @@ public boolean hasRegistrations() {
86
84
* Enable use of a {@link ContentNegotiatingViewResolver} to front all other
87
85
* configured view resolvers and select among all selected Views based on
88
86
* media types requested by the client (e.g. in the Accept header).
89
- *
90
87
* <p>If invoked multiple times the provided default views will be added to
91
88
* any other default views that may have been configured already.
92
- *
93
89
* @see ContentNegotiatingViewResolver#setDefaultViews
94
90
*/
95
91
public void enableContentNegotiation (View ... defaultViews ) {
@@ -100,7 +96,6 @@ public void enableContentNegotiation(View... defaultViews) {
100
96
* Enable use of a {@link ContentNegotiatingViewResolver} to front all other
101
97
* configured view resolvers and select among all selected Views based on
102
98
* media types requested by the client (e.g. in the Accept header).
103
- *
104
99
* <p>If invoked multiple times the provided default views will be added to
105
100
* any other default views that may have been configured already.
106
101
*
@@ -112,9 +107,8 @@ public void enableContentNegotiation(boolean useNotAcceptableStatus, View... def
112
107
}
113
108
114
109
private void initContentNegotiatingViewResolver (View [] defaultViews ) {
115
-
116
110
// ContentNegotiatingResolver in the registry: elevate its precedence!
117
- this .order = (this .order == null ? Ordered . HIGHEST_PRECEDENCE : this . order );
111
+ this .order = (this .order != null ? this . order : Ordered . HIGHEST_PRECEDENCE );
118
112
119
113
if (this .contentNegotiatingResolver != null ) {
120
114
if (!ObjectUtils .isEmpty (defaultViews )) {
@@ -136,7 +130,6 @@ private void initContentNegotiatingViewResolver(View[] defaultViews) {
136
130
/**
137
131
* Register JSP view resolver using a default view name prefix of "/WEB-INF/"
138
132
* and a default suffix of ".jsp".
139
- *
140
133
* <p>When this method is invoked more than once, each call will register a
141
134
* new ViewResolver instance. Note that since it's not easy to determine
142
135
* if a JSP exists without forwarding to it, using multiple JSP-based view
@@ -149,7 +142,6 @@ public UrlBasedViewResolverRegistration jsp() {
149
142
150
143
/**
151
144
* Register JSP view resolver with the specified prefix and suffix.
152
- *
153
145
* <p>When this method is invoked more than once, each call will register a
154
146
* new ViewResolver instance. Note that since it's not easy to determine
155
147
* if a JSP exists without forwarding to it, using multiple JSP-based view
@@ -166,7 +158,6 @@ public UrlBasedViewResolverRegistration jsp(String prefix, String suffix) {
166
158
167
159
/**
168
160
* Register Tiles 3.x view resolver.
169
- *
170
161
* <p><strong>Note</strong> that you must also configure Tiles by adding a
171
162
* {@link org.springframework.web.servlet.view.tiles3.TilesConfigurer} bean.
172
163
*/
@@ -184,7 +175,6 @@ public UrlBasedViewResolverRegistration tiles() {
184
175
/**
185
176
* Register a FreeMarker view resolver with an empty default view name
186
177
* prefix and a default suffix of ".ftl".
187
- *
188
178
* <p><strong>Note</strong> that you must also configure FreeMarker by adding a
189
179
* {@link org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer} bean.
190
180
*/
@@ -203,12 +193,13 @@ public UrlBasedViewResolverRegistration freeMarker() {
203
193
/**
204
194
* Register Velocity view resolver with an empty default view name
205
195
* prefix and a default suffix of ".vm".
206
- *
207
196
* <p><strong>Note</strong> that you must also configure Velocity by adding a
208
197
* {@link org.springframework.web.servlet.view.velocity.VelocityConfigurer} bean.
198
+ * @deprecated as of Spring 4.3, in favor of FreeMarker
209
199
*/
200
+ @ Deprecated
210
201
public UrlBasedViewResolverRegistration velocity () {
211
- if (this .applicationContext != null && !hasBeanOfType (VelocityConfigurer .class )) {
202
+ if (this .applicationContext != null && !hasBeanOfType (org . springframework . web . servlet . view . velocity . VelocityConfigurer .class )) {
212
203
throw new BeanInitializationException ("In addition to a Velocity view resolver " +
213
204
"there must also be a single VelocityConfig bean in this web application context " +
214
205
"(or its parent): VelocityConfigurer is the usual implementation. " +
@@ -313,38 +304,39 @@ protected List<ViewResolver> getViewResolvers() {
313
304
314
305
private static class TilesRegistration extends UrlBasedViewResolverRegistration {
315
306
316
- private TilesRegistration () {
307
+ public TilesRegistration () {
317
308
super (new TilesViewResolver ());
318
309
}
319
310
}
320
311
321
312
private static class VelocityRegistration extends UrlBasedViewResolverRegistration {
322
313
323
- private VelocityRegistration () {
324
- super (new VelocityViewResolver ());
314
+ @ SuppressWarnings ("deprecation" )
315
+ public VelocityRegistration () {
316
+ super (new org .springframework .web .servlet .view .velocity .VelocityViewResolver ());
325
317
getViewResolver ().setSuffix (".vm" );
326
318
}
327
319
}
328
320
329
321
private static class FreeMarkerRegistration extends UrlBasedViewResolverRegistration {
330
322
331
- private FreeMarkerRegistration () {
323
+ public FreeMarkerRegistration () {
332
324
super (new FreeMarkerViewResolver ());
333
325
getViewResolver ().setSuffix (".ftl" );
334
326
}
335
327
}
336
328
337
329
private static class GroovyMarkupRegistration extends UrlBasedViewResolverRegistration {
338
330
339
- private GroovyMarkupRegistration () {
331
+ public GroovyMarkupRegistration () {
340
332
super (new GroovyMarkupViewResolver ());
341
333
getViewResolver ().setSuffix (".tpl" );
342
334
}
343
335
}
344
336
345
337
private static class ScriptRegistration extends UrlBasedViewResolverRegistration {
346
338
347
- private ScriptRegistration () {
339
+ public ScriptRegistration () {
348
340
super (new ScriptTemplateViewResolver ());
349
341
getViewResolver ();
350
342
}
0 commit comments