extended checkResource(Locale) signature
This commit is contained in:
parent
2b13afd891
commit
68e07239c7
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.springframework.web.servlet.view;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
|
|
@ -78,11 +80,12 @@ public abstract class AbstractUrlBasedView extends AbstractView implements Initi
|
|||
/**
|
||||
* Check whether the underlying resource that the configured URL points to
|
||||
* actually exists.
|
||||
* @param locale the desired Locale that we're looking for
|
||||
* @return <code>true</code> if the resource exists (or is assumed to exist);
|
||||
* <code>false</code> if we know that it does not exist
|
||||
* @throws Exception if the resource exists but is invalid (e.g. could not be parsed)
|
||||
*/
|
||||
public boolean checkResource() throws Exception {
|
||||
public boolean checkResource(Locale locale) throws Exception {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
|
|||
protected View loadView(String viewName, Locale locale) throws Exception {
|
||||
AbstractUrlBasedView view = buildView(viewName);
|
||||
View result = (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);
|
||||
return (view.checkResource() ? result : null);
|
||||
return (view.checkResource(locale) ? result : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -197,10 +197,10 @@ public class FreeMarkerView extends AbstractTemplateView {
|
|||
* multiple templates to be rendered into a single view.
|
||||
*/
|
||||
@Override
|
||||
public boolean checkResource() throws Exception {
|
||||
public boolean checkResource(Locale locale) throws Exception {
|
||||
try {
|
||||
// Check that we can get the template, even if we might subsequently get it again.
|
||||
getTemplate(getUrl(), getConfiguration().getLocale());
|
||||
getTemplate(getUrl(), locale);
|
||||
return true;
|
||||
}
|
||||
catch (FileNotFoundException ex) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.web.servlet.view.velocity;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Locale;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.velocity.Template;
|
||||
|
|
@ -118,8 +119,8 @@ public class VelocityLayoutView extends VelocityToolboxView {
|
|||
* can be changed which may invalidate any early checking done here.
|
||||
*/
|
||||
@Override
|
||||
public boolean checkResource() throws Exception {
|
||||
if (!super.checkResource()) {
|
||||
public boolean checkResource(Locale locale) throws Exception {
|
||||
if (!super.checkResource(locale)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ public class VelocityView extends AbstractTemplateView {
|
|||
* multiple templates to be rendered into a single view.
|
||||
*/
|
||||
@Override
|
||||
public boolean checkResource() throws Exception {
|
||||
public boolean checkResource(Locale locale) throws Exception {
|
||||
try {
|
||||
// Check that we can get the template, even if we might subsequently get it again.
|
||||
this.template = getTemplate(getUrl());
|
||||
|
|
|
|||
Loading…
Reference in New Issue