50
50
* "/WEB-INF/jsp/test.jsp"
51
51
*
52
52
* <p>As a special feature, redirect URLs can be specified via the "redirect:"
53
- * prefix. E.g.: "redirect:myAction.do " will trigger a redirect to the given
53
+ * prefix. E.g.: "redirect:myAction" will trigger a redirect to the given
54
54
* URL, rather than resolution as standard view name. This is typically used
55
55
* for redirecting to a controller URL after finishing a form workflow.
56
56
*
57
- * <p>Furthermore, forward URLs can be specified via the "forward:" prefix. E.g.:
58
- * "forward:myAction.do " will trigger a forward to the given URL, rather than
57
+ * <p>Furthermore, forward URLs can be specified via the "forward:" prefix.
58
+ * E.g.: "forward:myAction" will trigger a forward to the given URL, rather than
59
59
* resolution as standard view name. This is typically used for controller URLs;
60
60
* it is not supposed to be used for JSP URLs - use logical view names there.
61
61
*
@@ -214,7 +214,7 @@ protected String getContentType() {
214
214
* interpreted as relative to the web application root, i.e. the context
215
215
* path will be prepended to the URL.
216
216
* <p><b>Redirect URLs can be specified via the "redirect:" prefix.</b>
217
- * E.g.: "redirect:myAction.do "
217
+ * E.g.: "redirect:myAction"
218
218
* @see RedirectView#setContextRelative
219
219
* @see #REDIRECT_URL_PREFIX
220
220
*/
@@ -241,7 +241,7 @@ protected boolean isRedirectContextRelative() {
241
241
* difference. However, some clients depend on 303 when redirecting
242
242
* after a POST request; turn this flag off in such a scenario.
243
243
* <p><b>Redirect URLs can be specified via the "redirect:" prefix.</b>
244
- * E.g.: "redirect:myAction.do "
244
+ * E.g.: "redirect:myAction"
245
245
* @see RedirectView#setHttp10Compatible
246
246
* @see #REDIRECT_URL_PREFIX
247
247
*/
@@ -342,7 +342,7 @@ public Map<String, Object> getAttributesMap() {
342
342
* <li>{@code true} - all Views resolved by this resolver will expose path variables
343
343
* <li>{@code false} - no Views resolved by this resolver will expose path variables
344
344
* <li>{@code null} - individual Views can decide for themselves (this is used by the default)
345
- * <ul>
345
+ * </ ul>
346
346
* @see AbstractView#setExposePathVariables
347
347
*/
348
348
public void setExposePathVariables (Boolean exposePathVariables ) {
@@ -453,18 +453,22 @@ protected View createView(String viewName, Locale locale) throws Exception {
453
453
if (!canHandle (viewName , locale )) {
454
454
return null ;
455
455
}
456
+
456
457
// Check for special "redirect:" prefix.
457
458
if (viewName .startsWith (REDIRECT_URL_PREFIX )) {
458
459
String redirectUrl = viewName .substring (REDIRECT_URL_PREFIX .length ());
459
- RedirectView view = new RedirectView (redirectUrl , isRedirectContextRelative (), isRedirectHttp10Compatible ());
460
+ RedirectView view = new RedirectView (redirectUrl ,
461
+ isRedirectContextRelative (), isRedirectHttp10Compatible ());
460
462
view .setHosts (getRedirectHosts ());
461
- return applyLifecycleMethods (viewName , view );
463
+ return applyLifecycleMethods (REDIRECT_URL_PREFIX , view );
462
464
}
465
+
463
466
// Check for special "forward:" prefix.
464
467
if (viewName .startsWith (FORWARD_URL_PREFIX )) {
465
468
String forwardUrl = viewName .substring (FORWARD_URL_PREFIX .length ());
466
469
return new InternalResourceView (forwardUrl );
467
470
}
471
+
468
472
// Else fall back to superclass implementation: calling loadView.
469
473
return super .createView (viewName , locale );
470
474
}
@@ -486,7 +490,7 @@ protected boolean canHandle(String viewName, Locale locale) {
486
490
487
491
/**
488
492
* Delegates to {@code buildView} for creating a new instance of the
489
- * specified view class, and applies the following Spring lifecycle methods
493
+ * specified view class. Applies the following Spring lifecycle methods
490
494
* (as supported by the generic Spring bean factory):
491
495
* <ul>
492
496
* <li>ApplicationContextAware's {@code setApplicationContext}
@@ -506,10 +510,6 @@ protected View loadView(String viewName, Locale locale) throws Exception {
506
510
return (view .checkResource (locale ) ? result : null );
507
511
}
508
512
509
- private View applyLifecycleMethods (String viewName , AbstractView view ) {
510
- return (View ) getApplicationContext ().getAutowireCapableBeanFactory ().initializeBean (view , viewName );
511
- }
512
-
513
513
/**
514
514
* Creates a new View instance of the specified view class and configures it.
515
515
* Does <i>not</i> perform any lookup for pre-defined View instances.
@@ -552,4 +552,8 @@ protected AbstractUrlBasedView buildView(String viewName) throws Exception {
552
552
return view ;
553
553
}
554
554
555
+ private View applyLifecycleMethods (String viewName , AbstractView view ) {
556
+ return (View ) getApplicationContext ().getAutowireCapableBeanFactory ().initializeBean (view , viewName );
557
+ }
558
+
555
559
}
0 commit comments