1 /* 2 * Copyright 2002-2005 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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; 18 19 import java.util.Locale; 20 21 /** 22 * Interface to be implemented by objects that can resolve views by name. 23 * 24 * <p>View state doesn't change during the running of the application, 25 * so implementations are free to cache views. 26 * 27 * <p>Implementations are encouraged to support internationalization, 28 * i.e. localized view resolution. 29 * 30 * @author Rod Johnson 31 * @author Juergen Hoeller 32 * @see org.springframework.web.servlet.view.InternalResourceViewResolver 33 * @see org.springframework.web.servlet.view.ResourceBundleViewResolver 34 * @see org.springframework.web.servlet.view.XmlViewResolver 35 */ 36 public interface ViewResolver { 37 38 /** 39 * Resolve the given view by name. 40 * <p>Note: To allow for ViewResolver chaining, a ViewResolver should 41 * return <code>null</code> if a view with the given name is not defined in it. 42 * However, this is not required: Some ViewResolvers will always attempt 43 * to build View objects with the given name, unable to return <code>null</code> 44 * (rather throwing an exception when View creation failed). 45 * @param viewName name of the view to resolve 46 * @param locale Locale in which to resolve the view. 47 * ViewResolvers that support internationalization should respect this. 48 * @return the View object, or <code>null</code> if not found 49 * (optional, to allow for ViewResolver chaining) 50 * @throws Exception if the view cannot be resolved 51 * (typically in case of problems creating an actual View object) 52 */ 53 View resolveViewName(String viewName, Locale locale) throws Exception; 54 55 } 56