import com.lancoo.common.core.text.Convert; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; /** * 权限信息 * * @author lancoo */ public class PermissionContextHolder { private static final String PERMISSION_CONTEXT_ATTRIBUTES = "PERMISSION_CONTEXT"; public static void setContext(String permission) { RequestContextHolder.currentRequestAttributes().setAttribute(PERMISSION_CONTEXT_ATTRIBUTES, permission, RequestAttributes.SCOPE_REQUEST); } public static String getContext() { return Convert.toStr(RequestContextHolder.currentRequestAttributes().getAttribute(PERMISSION_CONTEXT_ATTRIBUTES, RequestAttributes.SCOPE_REQUEST)); } }
权限信 息
文章介绍了PermissionContextHolder类,用于在SpringWeb请求上下文中存储和获取权限信息,通过RequestContextHolder进行操作,支持设置和获取特定范围的请求属性。
摘要由CSDN通过智能技术生成