All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nervousync.beans.servlet.request.RequestAttribute Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
/*
 * Licensed to the Nervousync Studio (NSYC) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.nervousync.beans.servlet.request;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import jakarta.annotation.Nonnull;
import jakarta.servlet.http.HttpServletRequest;

/**
 * 

Parsed request attributes from HttpServletRequest

*

从HttpServletRequest实例对象解析的属性信息

* * @author Steven Wee [email protected] * @version $Revision: 1.1.0 $ $Date: Aug 06, 2018 08:56:50 $ */ public final class RequestAttribute { /** * Session ID of current request * 当前请求的会话ID */ private final String sessionId; /** * Attributes map of current request * 当前请求包含的属性映射 */ private final Map attributeMap; /** *

Constructor for RequestAttribute

*

* Parse given HttpServletRequest instance, read session id, * all exists attributes and put attributes key-value map into field attributeMap *

*

RequestAttribute的构造方法

*

解析给定的HttpServletRequest实例对象,读取会话ID,将所有存在的属性键值对放入attributeMap

* * @param request HttpServletRequest instance, must not be null * HttpServletRequest实例对象,不允许为null */ public RequestAttribute(@Nonnull final HttpServletRequest request) { this.sessionId = request.getSession().getId(); this.attributeMap = new HashMap<>(); Enumeration e = request.getAttributeNames(); while (e.hasMoreElements()) { String name = e.nextElement(); this.attributeMap.put(name, request.getAttribute(name)); } } /** *

Getter method for Session ID

*

会话ID的Getter方法

*/ public String getSessionId() { return sessionId; } /** *

Getter method for attribute map

*

属性键值映射表的Getter方法

*/ public Map getAttributeMap() { return attributeMap; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy