类 WebMvcUtils


  • public abstract class WebMvcUtils
    extends java.lang.Object
    Spring Web MVC Utilities Class
    从以下版本开始:
    1.0.0
    作者:
    Mercy
    • 构造器概要

      构造器 
      构造器 说明
      WebMvcUtils()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static void appendContextInitializerClassInitParameter​(javax.servlet.ServletContext servletContext, java.lang.Class<? extends org.springframework.context.ApplicationContextInitializer> contextInitializerClass)
      Append initialized parameter for Context Initializer Class
      static void appendFrameworkServletContextInitializerClassInitParameter​(javax.servlet.ServletContext servletContext, java.lang.Class<? extends org.springframework.context.ApplicationContextInitializer> contextInitializerClass)
      Append initialized parameter for Context Initializer Class into FrameworkServlet
      static void appendGlobalInitializerClassInitParameter​(javax.servlet.ServletContext servletContext, java.lang.Class<? extends org.springframework.context.ApplicationContextInitializer> contextInitializerClass)
      Append initialized parameter for Global Initializer Class
      protected static java.lang.String appendInitParameter​(java.lang.String existedParameterValue, java.lang.String... parameterValues)  
      static void appendInitParameters​(javax.servlet.ServletContext servletContext, java.lang.String parameterName, java.lang.String... parameterValues)
      Append ServletContext Intialized Parameters
      static java.lang.Object[] getHandlerMethodArguments​(java.lang.reflect.Method method)
      Gets the HandlerMethod method parameter
      static java.lang.Object[] getHandlerMethodArguments​(javax.servlet.ServletRequest request, java.lang.reflect.Method method)
      Gets the HandlerMethod method parameter
      static java.lang.Object[] getHandlerMethodArguments​(javax.servlet.ServletRequest request, org.springframework.web.method.HandlerMethod handlerMethod)
      Gets the HandlerMethod method parameter
      static java.lang.Object[] getHandlerMethodArguments​(org.springframework.web.context.request.WebRequest webRequest, java.lang.reflect.Method method)  
      static java.lang.Object[] getHandlerMethodArguments​(org.springframework.web.context.request.WebRequest webRequest, org.springframework.core.MethodParameter parameter)  
      static java.lang.Object[] getHandlerMethodArguments​(org.springframework.web.context.request.WebRequest webRequest, org.springframework.web.method.HandlerMethod handlerMethod)  
      static <T> T getHandlerMethodRequestBodyArgument​(javax.servlet.ServletRequest request, java.lang.reflect.Method method)
      Gets the @RequestBody method parameter from the ServletRequest context
      static <T> T getHandlerMethodRequestBodyArgument​(javax.servlet.ServletRequest request, org.springframework.web.method.HandlerMethod handlerMethod)
      Gets the @RequestBody method parameter from the ServletRequest context
      static <T> T getHandlerMethodReturnValue​(java.lang.reflect.Method method)
      Gets the value returned by the HandlerMethod method
      static <T> T getHandlerMethodReturnValue​(javax.servlet.ServletRequest request, java.lang.reflect.Method method)
      Gets the value returned by the HandlerMethod method
      static <T> T getHandlerMethodReturnValue​(javax.servlet.ServletRequest request, org.springframework.web.method.HandlerMethod handlerMethod)
      Gets the value returned by the HandlerMethod method
      static javax.servlet.http.HttpServletRequest getHttpServletRequest()
      Gets the current HttpServletRequest object
      static javax.servlet.http.HttpServletRequest getHttpServletRequest​(org.springframework.web.context.request.WebRequest webRequest)  
      static org.springframework.web.context.WebApplicationContext getWebApplicationContext()
      Gets the WebApplicationContext associated with the current Servlet Request request
      static org.springframework.web.context.WebApplicationContext getWebApplicationContext​(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext servletContext)
      Get the WebApplicationContext from HttpServletRequest
      static boolean isControllerAdviceBeanType​(java.lang.Class<?> beanType)
      Determine whether the Bean Type is present annotated by ControllerAdvice
      static boolean isPageRenderRequest​(org.springframework.web.servlet.ModelAndView modelAndView)
      Is page render request
      static void setHandlerMethodRequestBodyArgument​(java.lang.reflect.Method method, java.lang.Object requestBodyArgument)
      Set the @RequestBody method parameter in HandlerMethod to the ServletRequest context
      static void setHandlerMethodRequestBodyArgument​(javax.servlet.ServletRequest request, java.lang.reflect.Method method, java.lang.Object requestBodyArgument)
      Set the @RequestBody method parameter in HandlerMethod to the ServletRequest context
      static void setHandlerMethodReturnValue​(javax.servlet.http.HttpServletRequest request, java.lang.reflect.Method method, java.lang.Object returnValue)  
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • HANDLER_METHOD_ARGUMENTS_ATTRIBUTE_NAME_PREFIX

        public static final java.lang.String HANDLER_METHOD_ARGUMENTS_ATTRIBUTE_NAME_PREFIX
        另请参阅:
        常量字段值
      • HANDLER_METHOD_REQUEST_BODY_ARGUMENT_ATTRIBUTE_NAME_PREFIX

        public static final java.lang.String HANDLER_METHOD_REQUEST_BODY_ARGUMENT_ATTRIBUTE_NAME_PREFIX
        另请参阅:
        常量字段值
      • HANDLER_METHOD_RETURN_VALUE_ATTRIBUTE_NAME_PREFIX

        public static final java.lang.String HANDLER_METHOD_RETURN_VALUE_ATTRIBUTE_NAME_PREFIX
        另请参阅:
        常量字段值
      • supportedConverterTypes

        public static final java.util.Set<java.lang.Class<? extends org.springframework.http.converter.HttpMessageConverter<?>>> supportedConverterTypes
      • ABSTRACT_JSONP_RESPONSE_BODY_ADVICE_CLASS_NAME

        public static final java.lang.String ABSTRACT_JSONP_RESPONSE_BODY_ADVICE_CLASS_NAME
        The name of AbstractJsonpResponseBodyAdvice class which was present in Spring Framework since 4.1
        另请参阅:
        常量字段值
    • 构造器详细资料

      • WebMvcUtils

        public WebMvcUtils()
    • 方法详细资料

      • getHttpServletRequest

        public static javax.servlet.http.HttpServletRequest getHttpServletRequest()
                                                                           throws java.lang.IllegalStateException
        Gets the current HttpServletRequest object

        By default, HttpServletRequest is initialized in RequestContextFilter, HttpServletRequest from the Servlet HTTP request thread ThreadLocal is obtained from InheritableThreadLocal and can be obtained in the child thread.

        返回:
        null returns the current HttpServletRequest object.
        抛出:
        java.lang.IllegalStateException
      • getHttpServletRequest

        public static javax.servlet.http.HttpServletRequest getHttpServletRequest​(org.springframework.web.context.request.WebRequest webRequest)
      • getWebApplicationContext

        public static org.springframework.web.context.WebApplicationContext getWebApplicationContext()
                                                                                              throws java.lang.IllegalStateException
        Gets the WebApplicationContext associated with the current Servlet Request request
        返回:
        Current Servlet Request associated with WebApplicationContext
        抛出:
        java.lang.IllegalStateException - In a non-Web scenario, an exception is thrown
      • setHandlerMethodRequestBodyArgument

        public static void setHandlerMethodRequestBodyArgument​(java.lang.reflect.Method method,
                                                               java.lang.Object requestBodyArgument)
        Set the @RequestBody method parameter in HandlerMethod to the ServletRequest context
        参数:
        method - Handler Method
        requestBodyArgument - @RequestBody The method parameters
      • setHandlerMethodReturnValue

        public static void setHandlerMethodReturnValue​(javax.servlet.http.HttpServletRequest request,
                                                       java.lang.reflect.Method method,
                                                       java.lang.Object returnValue)
      • setHandlerMethodRequestBodyArgument

        public static void setHandlerMethodRequestBodyArgument​(javax.servlet.ServletRequest request,
                                                               java.lang.reflect.Method method,
                                                               java.lang.Object requestBodyArgument)
        Set the @RequestBody method parameter in HandlerMethod to the ServletRequest context
        参数:
        request - ServletRequest
        method - Handler Method
        requestBodyArgument - @RequestBody The method parameters
      • getHandlerMethodRequestBodyArgument

        public static <T> T getHandlerMethodRequestBodyArgument​(javax.servlet.ServletRequest request,
                                                                org.springframework.web.method.HandlerMethod handlerMethod)
        Gets the @RequestBody method parameter from the ServletRequest context
        类型参数:
        T - @RequestBody Method parameter Types
        参数:
        request - ServletRequest
        handlerMethod - HandlerMethod
        返回:
        @RequestBody Method parameters if present, otherwise,null
      • getHandlerMethodRequestBodyArgument

        public static <T> T getHandlerMethodRequestBodyArgument​(javax.servlet.ServletRequest request,
                                                                java.lang.reflect.Method method)
        Gets the @RequestBody method parameter from the ServletRequest context
        类型参数:
        T - @RequestBody Method parameter Types
        参数:
        request - ServletRequest
        method - Handler Method
        返回:
        @RequestBody method parameter if present, otherwise null
      • getHandlerMethodArguments

        public static java.lang.Object[] getHandlerMethodArguments​(org.springframework.web.context.request.WebRequest webRequest,
                                                                   org.springframework.web.method.HandlerMethod handlerMethod)
      • getHandlerMethodArguments

        public static java.lang.Object[] getHandlerMethodArguments​(org.springframework.web.context.request.WebRequest webRequest,
                                                                   org.springframework.core.MethodParameter parameter)
      • getHandlerMethodArguments

        public static java.lang.Object[] getHandlerMethodArguments​(org.springframework.web.context.request.WebRequest webRequest,
                                                                   java.lang.reflect.Method method)
      • getHandlerMethodArguments

        public static java.lang.Object[] getHandlerMethodArguments​(javax.servlet.ServletRequest request,
                                                                   org.springframework.web.method.HandlerMethod handlerMethod)
        Gets the HandlerMethod method parameter
        参数:
        request - ServletRequest
        handlerMethod - HandlerMethod
        返回:
        non-null
      • getHandlerMethodArguments

        public static java.lang.Object[] getHandlerMethodArguments​(javax.servlet.ServletRequest request,
                                                                   java.lang.reflect.Method method)
        Gets the HandlerMethod method parameter
        参数:
        request - ServletRequest
        method - Method
        返回:
        non-null
      • getHandlerMethodArguments

        public static java.lang.Object[] getHandlerMethodArguments​(java.lang.reflect.Method method)
        Gets the HandlerMethod method parameter
        参数:
        method - Method
        返回:
        non-null
      • getHandlerMethodReturnValue

        public static <T> T getHandlerMethodReturnValue​(javax.servlet.ServletRequest request,
                                                        org.springframework.web.method.HandlerMethod handlerMethod)
        Gets the value returned by the HandlerMethod method
        类型参数:
        T - Method return value type
        参数:
        request - ServletRequest
        handlerMethod - HandlerMethod
        返回:
        HandlerMethod Method return value
      • getHandlerMethodReturnValue

        public static <T> T getHandlerMethodReturnValue​(javax.servlet.ServletRequest request,
                                                        java.lang.reflect.Method method)
        Gets the value returned by the HandlerMethod method
        类型参数:
        T - Method return value type
        参数:
        request - ServletRequest
        method - Method
        返回:
        HandlerMethod Method return value
      • getHandlerMethodReturnValue

        public static <T> T getHandlerMethodReturnValue​(java.lang.reflect.Method method)
        Gets the value returned by the HandlerMethod method
        类型参数:
        T - Method return value type
        参数:
        method - Method
        返回:
        HandlerMethod Method return value
      • isControllerAdviceBeanType

        public static boolean isControllerAdviceBeanType​(java.lang.Class<?> beanType)
        Determine whether the Bean Type is present annotated by ControllerAdvice
        参数:
        beanType - Bean Type
        返回:
        If ControllerAdvice bean type is present , return true , or false.
      • getWebApplicationContext

        public static org.springframework.web.context.WebApplicationContext getWebApplicationContext​(javax.servlet.http.HttpServletRequest request,
                                                                                                     javax.servlet.ServletContext servletContext)
        Get the WebApplicationContext from HttpServletRequest
        参数:
        request - HttpServletRequest
        servletContext - ServletContext
        返回:
        WebApplicationContext
        抛出:
        java.lang.IllegalStateException - if no servlet-specific context has been found
        另请参阅:
        RequestContextUtils#getWebApplicationContext(ServletRequest), DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE
      • appendInitParameter

        protected static java.lang.String appendInitParameter​(java.lang.String existedParameterValue,
                                                              java.lang.String... parameterValues)
      • appendInitParameters

        public static void appendInitParameters​(javax.servlet.ServletContext servletContext,
                                                java.lang.String parameterName,
                                                java.lang.String... parameterValues)
        Append ServletContext Intialized Parameters
        参数:
        servletContext - ServletContext
        parameterName - the name of init parameter
        parameterValues - the values of init parameters
      • appendGlobalInitializerClassInitParameter

        public static void appendGlobalInitializerClassInitParameter​(javax.servlet.ServletContext servletContext,
                                                                     java.lang.Class<? extends org.springframework.context.ApplicationContextInitializer> contextInitializerClass)
        Append initialized parameter for Global Initializer Class
        参数:
        servletContext - ServletContext
        contextInitializerClass - the class of ApplicationContextInitializer
        另请参阅:
        ContextLoader.GLOBAL_INITIALIZER_CLASSES_PARAM
      • appendContextInitializerClassInitParameter

        public static void appendContextInitializerClassInitParameter​(javax.servlet.ServletContext servletContext,
                                                                      java.lang.Class<? extends org.springframework.context.ApplicationContextInitializer> contextInitializerClass)
        Append initialized parameter for Context Initializer Class
        参数:
        servletContext - ServletContext
        contextInitializerClass - the class of ApplicationContextInitializer
        另请参阅:
        ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM
      • appendFrameworkServletContextInitializerClassInitParameter

        public static void appendFrameworkServletContextInitializerClassInitParameter​(javax.servlet.ServletContext servletContext,
                                                                                      java.lang.Class<? extends org.springframework.context.ApplicationContextInitializer> contextInitializerClass)
        Append initialized parameter for Context Initializer Class into FrameworkServlet
        参数:
        servletContext - ServletContext
        contextInitializerClass - the class of ApplicationContextInitializer
        另请参阅:
        FrameworkServlet.applyInitializers(ConfigurableApplicationContext)
      • isPageRenderRequest

        public static boolean isPageRenderRequest​(org.springframework.web.servlet.ModelAndView modelAndView)
        Is page render request
        参数:
        modelAndView - ModelAndView
        返回:
        If current request is for page render , return true , or false.