类的使用
org.springframework.web.servlet.ModelAndView
使用ModelAndView的程序包 程序包 说明 org.springframework.test.web Helper classes for unit tests based on Spring's web support.org.springframework.test.web.servlet Contains server-side support for testing Spring MVC applications.org.springframework.test.web.servlet.result Contains built-inResultMatcherandResultHandlerimplementations.org.springframework.web.servlet Provides servlets that integrate with the application context infrastructure, and the core interfaces and classes for the Spring web MVC framework.org.springframework.web.servlet.function Provides the types that make up Spring's functional web framework for Servlet environments.org.springframework.web.servlet.function.support Classes supporting theorg.springframework.web.servlet.functionpackage.org.springframework.web.servlet.handler Provides standard HandlerMapping implementations, including abstract base classes for custom implementations.org.springframework.web.servlet.mvc Standard controller implementations for the Servlet MVC framework that comes with Spring.org.springframework.web.servlet.mvc.annotation Support package for annotation-based Servlet MVC controllers.org.springframework.web.servlet.mvc.method Servlet-based infrastructure for handler method processing, building on theorg.springframework.web.methodpackage.org.springframework.web.servlet.mvc.method.annotation MVC infrastructure for annotation-based handler method processing, building on theorg.springframework.web.method.annotationpackage.org.springframework.web.servlet.mvc.support Support package for MVC controllers.org.springframework.test.web中ModelAndView的使用
参数类型为ModelAndView的org.springframework.test.web中的方法 修饰符和类型 方法 说明 static <T> TModelAndViewAssert. assertAndReturnModelAttributeOfType(ModelAndView mav, String modelName, Class<T> expectedType)Checks whether the model value under the givenmodelNameexists and checks it type, based on theexpectedType.static voidModelAndViewAssert. assertCompareListModelAttribute(ModelAndView mav, String modelName, List expectedList)Compare each individual entry in a list, without first sorting the lists.static voidModelAndViewAssert. assertModelAttributeAvailable(ModelAndView mav, String modelName)Assert whether or not a model attribute is available.static voidModelAndViewAssert. assertModelAttributeValue(ModelAndView mav, String modelName, Object expectedValue)Compare a givenexpectedValueto the value from the model bound under the givenmodelName.static voidModelAndViewAssert. assertModelAttributeValues(ModelAndView mav, Map<String,Object> expectedModel)Inspect theexpectedModelto see if all elements in the model appear and are equal.static voidModelAndViewAssert. assertSortAndCompareListModelAttribute(ModelAndView mav, String modelName, List expectedList, Comparator comparator)Compare each individual entry in a list after having sorted both lists (optionally using a comparator).static voidModelAndViewAssert. assertViewName(ModelAndView mav, String expectedName)Check to see if the view name in the ModelAndView matches the givenexpectedName.org.springframework.test.web.servlet中ModelAndView的使用
返回ModelAndView的org.springframework.test.web.servlet中的方法 修饰符和类型 方法 说明 ModelAndViewMvcResult. getModelAndView()Return theModelAndViewprepared by the handler.org.springframework.test.web.servlet.result中ModelAndView的使用
参数类型为ModelAndView的org.springframework.test.web.servlet.result中的方法 修饰符和类型 方法 说明 protected voidPrintingResultHandler. printModelAndView(ModelAndView mav)Print the ModelAndView.org.springframework.web.servlet中ModelAndView的使用
返回ModelAndView的org.springframework.web.servlet中的方法 修饰符和类型 方法 说明 ModelAndViewModelAndView. addAllObjects(Map<String,?> modelMap)Add all attributes contained in the provided Map to the model.ModelAndViewModelAndView. addObject(Object attributeValue)Add an attribute to the model using parameter name generation.ModelAndViewModelAndView. addObject(String attributeName, Object attributeValue)Add an attribute to the model.ModelAndViewModelAndViewDefiningException. getModelAndView()Return the ModelAndView that this exception contains for forwarding to.ModelAndViewHandlerAdapter. handle(HttpServletRequest request, HttpServletResponse response, Object handler)Use the given handler to handle this request.protected ModelAndViewDispatcherServlet. processHandlerException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)Determine an error ModelAndView via the registered HandlerExceptionResolvers.ModelAndViewHandlerExceptionResolver. resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)Try to resolve the given exception that got thrown during handler execution, returning aModelAndViewthat represents a specific error page if appropriate.参数类型为ModelAndView的org.springframework.web.servlet中的方法 修饰符和类型 方法 说明 default voidHandlerInterceptor. postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)Intercept the execution of a handler.protected voidDispatcherServlet. render(ModelAndView mv, HttpServletRequest request, HttpServletResponse response)Render the given ModelAndView.参数类型为ModelAndView的org.springframework.web.servlet中的构造器 构造器 说明 ModelAndViewDefiningException(ModelAndView modelAndView)Create new ModelAndViewDefiningException with the given ModelAndView, typically representing a specific error page.org.springframework.web.servlet.function中ModelAndView的使用
返回ModelAndView的org.springframework.web.servlet.function中的方法 修饰符和类型 方法 说明 ModelAndViewServerResponse. writeTo(HttpServletRequest request, HttpServletResponse response, ServerResponse.Context context)Write this response to the given servlet response.类型变量类型为ModelAndView的org.springframework.web.servlet.function中的方法参数 修饰符和类型 方法 说明 ServerResponseServerResponse.HeadersBuilder. build(BiFunction<HttpServletRequest,HttpServletResponse,ModelAndView> writeFunction)Build the response entity with a custom write function.org.springframework.web.servlet.function.support中ModelAndView的使用
返回ModelAndView的org.springframework.web.servlet.function.support中的方法 修饰符和类型 方法 说明 ModelAndViewHandlerFunctionAdapter. handle(HttpServletRequest servletRequest, HttpServletResponse servletResponse, Object handler)org.springframework.web.servlet.handler中ModelAndView的使用
返回ModelAndView的org.springframework.web.servlet.handler中的方法 修饰符和类型 方法 说明 protected abstract ModelAndViewAbstractHandlerExceptionResolver. doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)Actually resolve the given exception that got thrown during handler execution, returning aModelAndViewthat represents a specific error page if appropriate.protected ModelAndViewAbstractHandlerMethodExceptionResolver. doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)protected ModelAndViewSimpleMappingExceptionResolver. doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)Actually resolve the given exception that got thrown during on handler execution, returning a ModelAndView that represents a specific error page if appropriate.protected abstract ModelAndViewAbstractHandlerMethodExceptionResolver. doResolveHandlerMethodException(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod, Exception ex)Actually resolve the given exception that got thrown during on handler execution, returning a ModelAndView that represents a specific error page if appropriate.protected ModelAndViewSimpleMappingExceptionResolver. getModelAndView(String viewName, Exception ex)Return a ModelAndView for the given view name and exception.protected ModelAndViewSimpleMappingExceptionResolver. getModelAndView(String viewName, Exception ex, HttpServletRequest request)Return a ModelAndView for the given request, view name and exception.ModelAndViewSimpleServletHandlerAdapter. handle(HttpServletRequest request, HttpServletResponse response, Object handler)ModelAndViewAbstractHandlerExceptionResolver. resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)Check whether this resolver is supposed to apply (i.e. if the supplied handler matches any of the configured handlers or handler classes), and then delegate to theAbstractHandlerExceptionResolver.doResolveException(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, java.lang.Exception)template method.ModelAndViewHandlerExceptionResolverComposite. resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)Resolve the exception by iterating over the list of configured exception resolvers.参数类型为ModelAndView的org.springframework.web.servlet.handler中的方法 修饰符和类型 方法 说明 voidHandlerInterceptorAdapter. postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)This implementation is empty.voidMappedInterceptor. postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)voidWebRequestHandlerInterceptorAdapter. postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)org.springframework.web.servlet.mvc中ModelAndView的使用
返回ModelAndView的org.springframework.web.servlet.mvc中的方法 修饰符和类型 方法 说明 ModelAndViewHttpRequestHandlerAdapter. handle(HttpServletRequest request, HttpServletResponse response, Object handler)ModelAndViewSimpleControllerHandlerAdapter. handle(HttpServletRequest request, HttpServletResponse response, Object handler)ModelAndViewAbstractController. handleRequest(HttpServletRequest request, HttpServletResponse response)ModelAndViewController. handleRequest(HttpServletRequest request, HttpServletResponse response)Process the request and return a ModelAndView object which the DispatcherServlet will render.protected abstract ModelAndViewAbstractController. handleRequestInternal(HttpServletRequest request, HttpServletResponse response)Template method.protected ModelAndViewAbstractUrlViewController. handleRequestInternal(HttpServletRequest request, HttpServletResponse response)Retrieves the URL path to use for lookup and delegates toAbstractUrlViewController.getViewNameForRequest(javax.servlet.http.HttpServletRequest).protected ModelAndViewParameterizableViewController. handleRequestInternal(HttpServletRequest request, HttpServletResponse response)Return a ModelAndView object with the specified view name.protected ModelAndViewServletForwardingController. handleRequestInternal(HttpServletRequest request, HttpServletResponse response)protected ModelAndViewServletWrappingController. handleRequestInternal(HttpServletRequest request, HttpServletResponse response)Invoke the wrapped Servlet instance.参数类型为ModelAndView的org.springframework.web.servlet.mvc中的方法 修饰符和类型 方法 说明 voidWebContentInterceptor. postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)This implementation is empty.org.springframework.web.servlet.mvc.annotation中ModelAndView的使用
声明为ModelAndView的org.springframework.web.servlet.mvc.annotation中的字段 修饰符和类型 字段 说明 static ModelAndViewModelAndViewResolver. UNRESOLVEDMarker to be returned when the resolver does not know how to handle the given method parameter.返回ModelAndView的org.springframework.web.servlet.mvc.annotation中的方法 修饰符和类型 方法 说明 protected ModelAndViewResponseStatusExceptionResolver. applyStatusAndReason(int statusCode, String reason, HttpServletResponse response)Apply the resolved status code and reason to the response.protected ModelAndViewResponseStatusExceptionResolver. doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)ModelAndViewModelAndViewResolver. resolveModelAndView(Method handlerMethod, Class<?> handlerType, Object returnValue, ExtendedModelMap implicitModel, NativeWebRequest webRequest)protected ModelAndViewResponseStatusExceptionResolver. resolveResponseStatus(ResponseStatus responseStatus, HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)Template method that handles the@ResponseStatusannotation.protected ModelAndViewResponseStatusExceptionResolver. resolveResponseStatusException(ResponseStatusException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Template method that handles anResponseStatusException.org.springframework.web.servlet.mvc.method中ModelAndView的使用
返回ModelAndView的org.springframework.web.servlet.mvc.method中的方法 修饰符和类型 方法 说明 ModelAndViewAbstractHandlerMethodAdapter. handle(HttpServletRequest request, HttpServletResponse response, Object handler)This implementation expects the handler to be anHandlerMethod.protected abstract ModelAndViewAbstractHandlerMethodAdapter. handleInternal(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod)Use the given handler method to handle the request.org.springframework.web.servlet.mvc.method.annotation中ModelAndView的使用
返回ModelAndView的org.springframework.web.servlet.mvc.method.annotation中的方法 修饰符和类型 方法 说明 protected ModelAndViewExceptionHandlerExceptionResolver. doResolveHandlerMethodException(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod, Exception exception)Find an@ExceptionHandlermethod and invoke it to handle the raised exception.protected ModelAndViewRequestMappingHandlerAdapter. handleInternal(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod)protected ModelAndViewRequestMappingHandlerAdapter. invokeHandlerMethod(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod)Invoke theRequestMappinghandler method preparing aModelAndViewif view resolution is required.org.springframework.web.servlet.mvc.support中ModelAndView的使用
返回ModelAndView的org.springframework.web.servlet.mvc.support中的方法 修饰符和类型 方法 说明 protected ModelAndViewDefaultHandlerExceptionResolver. doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)protected ModelAndViewDefaultHandlerExceptionResolver. handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case where an async request timed out.protected ModelAndViewDefaultHandlerExceptionResolver. handleBindException(BindException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case where an @ModelAttribute method argument has binding or validation errors and is not followed by another method argument of typeBindingResult.protected ModelAndViewDefaultHandlerExceptionResolver. handleConversionNotSupported(ConversionNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case when aWebDataBinderconversion cannot occur.protected ModelAndViewDefaultHandlerExceptionResolver. handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case where no message converters were found that were acceptable for the client (expressed via theAcceptheader.protected ModelAndViewDefaultHandlerExceptionResolver. handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case where no message converters were found for the PUT or POSTed content.protected ModelAndViewDefaultHandlerExceptionResolver. handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case where a message converter cannot read from an HTTP request.protected ModelAndViewDefaultHandlerExceptionResolver. handleHttpMessageNotWritable(HttpMessageNotWritableException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case where a message converter cannot write to an HTTP request.protected ModelAndViewDefaultHandlerExceptionResolver. handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case where no request handler method was found for the particular HTTP request method.protected ModelAndViewDefaultHandlerExceptionResolver. handleMethodArgumentNotValidException(MethodArgumentNotValidException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case where an argument annotated with@Validsuch as anRequestBodyorRequestPartargument fails validation.protected ModelAndViewDefaultHandlerExceptionResolver. handleMissingPathVariable(MissingPathVariableException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case when a declared path variable does not match any extracted URI variable.protected ModelAndViewDefaultHandlerExceptionResolver. handleMissingServletRequestParameter(MissingServletRequestParameterException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case when a required parameter is missing.protected ModelAndViewDefaultHandlerExceptionResolver. handleMissingServletRequestPartException(MissingServletRequestPartException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case where an @RequestPart, aMultipartFile, or ajavax.servlet.http.Partargument is required but is missing.protected ModelAndViewDefaultHandlerExceptionResolver. handleNoHandlerFoundException(NoHandlerFoundException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case where no handler was found during the dispatch.protected ModelAndViewDefaultHandlerExceptionResolver. handleServletRequestBindingException(ServletRequestBindingException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case when an unrecoverable binding exception occurs - e.g. required header, required cookie.protected ModelAndViewDefaultHandlerExceptionResolver. handleTypeMismatch(TypeMismatchException ex, HttpServletRequest request, HttpServletResponse response, Object handler)Handle the case when aWebDataBinderconversion error occurs.