001/* 002 * Copyright 2002-2015 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.web.servlet.mvc.annotation; 018 019import java.lang.reflect.Method; 020 021import org.springframework.ui.ExtendedModelMap; 022import org.springframework.web.context.request.NativeWebRequest; 023import org.springframework.web.servlet.ModelAndView; 024 025/** 026 * SPI for resolving custom return values from a specific handler method. 027 * Typically implemented to detect special return types, resolving 028 * well-known result values for them. 029 * 030 * <p>A typical implementation could look like as follows: 031 * 032 * <pre class="code"> 033 * public class MyModelAndViewResolver implements ModelAndViewResolver { 034 * 035 * public ModelAndView resolveModelAndView(Method handlerMethod, Class handlerType, 036 * Object returnValue, ExtendedModelMap implicitModel, NativeWebRequest webRequest) { 037 * if (returnValue instanceof MySpecialRetVal.class)) { 038 * return new MySpecialRetVal(returnValue); 039 * } 040 * return UNRESOLVED; 041 * } 042 * }</pre> 043 * 044 * @author Arjen Poutsma 045 * @since 3.0 046 */ 047public interface ModelAndViewResolver { 048 049 /** 050 * Marker to be returned when the resolver does not know how to handle the given method parameter. 051 */ 052 ModelAndView UNRESOLVED = new ModelAndView(); 053 054 055 ModelAndView resolveModelAndView(Method handlerMethod, Class<?> handlerType, Object returnValue, 056 ExtendedModelMap implicitModel, NativeWebRequest webRequest); 057 058}