Skip to content

io microsphere spring web util WebScope

github-actions[bot] edited this page Jun 18, 2026 · 18 revisions

WebScope

Type: Enum | 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/WebScope.java

Overview

The enumeration of scopes for Spring Web

Declaration

public enum WebScope

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.27-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.WebScope;

API Reference

Public Methods

Method Description
value Request Scope
getAttribute Return the request attribute value if present.
setAttribute Set the request attribute value.
removeAttribute Remove the request attribute by the specified name.
getRequiredAttribute Return the request attribute value or if not present raise an
getAttributeOrDefault Return the request attribute value, or a default, fallback value.
getAttributeNames Get all attribute names in the specified RequestAttributes.
clearAttributes Clear all attributes in the specified RequestAttributes.
valueOf Resolve the WebScope by the specified scope value
getAttribute Get the attribute value by the specified name
setAttribute Set the attribute value
removeAttribute Remove the attribute by the specified name
getAttributeNames Get all attribute names in the specified RequestAttributes by the scope
clearAttributes Clear all attributes in the specified RequestAttributes by the scope

Method Details

removeAttribute

public Object removeAttribute(@Nonnull RequestAttributes requestAttributes, @Nullable String name)

Remove the request attribute by the specified name.

getRequiredAttribute

public <T> T getRequiredAttribute(@Nonnull RequestAttributes requestAttributes, @Nullable String name)

Return the request attribute value or if not present raise an IllegalArgumentException.

getAttributeOrDefault

public <T> T getAttributeOrDefault(@Nonnull RequestAttributes requestAttributes, @Nullable String name,
                                       @Nullable T defaultValue)

Return the request attribute value, or a default, fallback value.

getAttributeNames

public String[] getAttributeNames(@Nonnull RequestAttributes requestAttributes)

Get all attribute names in the specified RequestAttributes.

clearAttributes

public void clearAttributes(@Nonnull RequestAttributes requestAttributes)

Clear all attributes in the specified RequestAttributes.

valueOf

public static WebScope valueOf(int scope)

Resolve the WebScope by the specified scope value

getAttributeNames

public static String[] getAttributeNames(@Nonnull RequestAttributes requestAttributes, int scope)

Get all attribute names in the specified RequestAttributes by the scope

clearAttributes

public static void clearAttributes(@Nonnull RequestAttributes requestAttributes, int scope)

Clear all attributes in the specified RequestAttributes by the scope

See Also

  • RequestAttributes#SCOPE_REQUEST
  • RequestAttributes#SCOPE_SESSION

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