Skip to content

io microsphere spring web util RequestAttributesUtils

github-actions[bot] edited this page Jul 11, 2026 · 25 revisions

RequestAttributesUtils

Type: Class | Module: microsphere-spring-web | Package: io.microsphere.spring.web.util | Since: 1.0.0

Source: microsphere-spring-web/src/main/java/io/microsphere/spring/web/util/RequestAttributesUtils.java

Overview

RequestAttributes Utilities Class

Declaration

public abstract class RequestAttributesUtils

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.36-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-web</artifactId>
    <version>${microsphere-spring.version}</version>
</dependency>

Tip: Use the BOM (microsphere-spring-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.spring.web.util.RequestAttributesUtils;

API Reference

Public Methods

Method Description
setRequestAttribute The prefix of the attribute name of the HandlerMethod method parameter
getRequestAttribute Get an attribute from the RequestAttributes with the specified name.
setHandlerMethodRequestBodyArgument Set the RequestBody @RequestBody method parameter in HandlerMethod to the RequestAttributes
setHandlerMethodRequestBodyArgument Set the RequestBody @RequestBody method parameter in HandlerMethod to the RequestAttributes
getHandlerMethodRequestBodyArgument Gets the RequestBody @RequestBody method parameter from the RequestContextHolder#getRequestAttributes()
getHandlerMethodRequestBodyArgument Gets the RequestBody @RequestBody method parameter from the RequestAttributes
getHandlerMethodRequestBodyArgument Gets the RequestBody @RequestBody method parameter from the RequestContextHolder#getRequestAttributes()
getHandlerMethodRequestBodyArgument Gets the RequestBody @RequestBody method parameter from the RequestAttributes
getHandlerMethodArguments Gets the HandlerMethod method parameter from the RequestContextHolder#getRequestAttributes()
getHandlerMethodArguments Gets the HandlerMethod method parameter
getHandlerMethodArguments Gets the HandlerMethod method parameter from the RequestContextHolder#getRequestAttributes()
getHandlerMethodArguments Gets the HandlerMethod method parameter from the RequestContextHolder#getRequestAttributes()
getHandlerMethodArguments Gets the HandlerMethod method parameter from the RequestContextHolder#getRequestAttributes()
getHandlerMethodArguments Gets the HandlerMethod method parameter
setHandlerMethodReturnValue Set the HandlerMethod method return value to the RequestContextHolder#getRequestAttributes()
setHandlerMethodReturnValue Set the HandlerMethod method return value to the RequestAttributes
getHandlerMethodReturnValue Gets the value returned by the HandlerMethod method from the RequestContextHolder#getRequestAttributes()
getHandlerMethodReturnValue Gets the value returned by the HandlerMethod method
getHandlerMethodReturnValue Gets the value returned by the HandlerMethod method from the RequestContextHolder#getRequestAttributes()
getHandlerMethodReturnValue Gets the value returned by the HandlerMethod method

Method Details

setRequestAttribute

public static void setRequestAttribute(@Nonnull RequestAttributes requestAttributes, @Nullable String attributeName,
                                           @Nullable Object attributeValue)

The prefix of the attribute name of the HandlerMethod method parameter / public static final String HANDLER_METHOD_ARGUMENTS_ATTRIBUTE_NAME_PREFIX = "HM.ARGS:";

/** The prefix of the attribute name of the HandlerMethod method parameter annotated ResponseBody / public static final String HANDLER_METHOD_REQUEST_BODY_ARGUMENT_ATTRIBUTE_NAME_PREFIX = "HM.RB.ARG:";

/** The prefix of the attribute name of the HandlerMethod method return value / public static final String HANDLER_METHOD_RETURN_VALUE_ATTRIBUTE_NAME_PREFIX = "HM.RV:";

/** Set an attribute to the RequestAttributes with the specified name and value.

getRequestAttribute

public static <T> T getRequestAttribute(@Nonnull RequestAttributes requestAttributes, String attributeName)

Get an attribute from the RequestAttributes with the specified name.

setHandlerMethodRequestBodyArgument

public static void setHandlerMethodRequestBodyArgument(Method method, Object requestBodyArgument)

Set the RequestBody @RequestBody method parameter in HandlerMethod to the RequestAttributes

setHandlerMethodRequestBodyArgument

public static void setHandlerMethodRequestBodyArgument(RequestAttributes requestAttributes, Method method, Object requestBodyArgument)

Set the RequestBody @RequestBody method parameter in HandlerMethod to the RequestAttributes

getHandlerMethodRequestBodyArgument

public static <T> T getHandlerMethodRequestBodyArgument(HandlerMethod handlerMethod)

Gets the RequestBody @RequestBody method parameter from the RequestContextHolder#getRequestAttributes()

getHandlerMethodRequestBodyArgument

public static <T> T getHandlerMethodRequestBodyArgument(RequestAttributes requestAttributes, HandlerMethod handlerMethod)

Gets the RequestBody @RequestBody method parameter from the RequestAttributes

getHandlerMethodRequestBodyArgument

public static <T> T getHandlerMethodRequestBodyArgument(Method method)

Gets the RequestBody @RequestBody method parameter from the RequestContextHolder#getRequestAttributes()

getHandlerMethodRequestBodyArgument

public static <T> T getHandlerMethodRequestBodyArgument(RequestAttributes requestAttributes, Method method)

Gets the RequestBody @RequestBody method parameter from the RequestAttributes

getHandlerMethodArguments

public static Object[] getHandlerMethodArguments(HandlerMethod handlerMethod)

Gets the HandlerMethod method parameter from the RequestContextHolder#getRequestAttributes()

getHandlerMethodArguments

public static Object[] getHandlerMethodArguments(MethodParameter parameter)

Gets the HandlerMethod method parameter from the RequestContextHolder#getRequestAttributes()

getHandlerMethodArguments

public static Object[] getHandlerMethodArguments(RequestAttributes requestAttributes, MethodParameter parameter)

Gets the HandlerMethod method parameter from the RequestContextHolder#getRequestAttributes()

getHandlerMethodArguments

public static Object[] getHandlerMethodArguments(Method method)

Gets the HandlerMethod method parameter from the RequestContextHolder#getRequestAttributes()

setHandlerMethodReturnValue

public static void setHandlerMethodReturnValue(Method method, Object returnValue)

Set the HandlerMethod method return value to the RequestContextHolder#getRequestAttributes()

setHandlerMethodReturnValue

public static void setHandlerMethodReturnValue(RequestAttributes requestAttributes, Method method, Object returnValue)

Set the HandlerMethod method return value to the RequestAttributes

getHandlerMethodReturnValue

public static <T> T getHandlerMethodReturnValue(HandlerMethod handlerMethod)

Gets the value returned by the HandlerMethod method from the RequestContextHolder#getRequestAttributes()

getHandlerMethodReturnValue

public static <T> T getHandlerMethodReturnValue(RequestAttributes requestAttributes, HandlerMethod handlerMethod)

Gets the value returned by the HandlerMethod method

getHandlerMethodReturnValue

public static <T> T getHandlerMethodReturnValue(Method method)

Gets the value returned by the HandlerMethod method from the RequestContextHolder#getRequestAttributes()

getHandlerMethodReturnValue

public static <T> T getHandlerMethodReturnValue(RequestAttributes requestAttributes, Method method)

Gets the value returned by the HandlerMethod method

See Also

  • RequestAttributesUtils

This documentation was auto-generated from the source code of microsphere-spring.

Home

spring-context

spring-guice

spring-jdbc

spring-test

spring-web

spring-webflux

spring-webmvc

Clone this wiki locally