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

com.holly.unit.validator.api.context.RequestParamContext Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package com.holly.unit.validator.api.context;

import cn.hutool.core.lang.Dict;

/**
 * 临时保存http请求的参数
 * 

* 可以保存@RequestBody的可以保存parameter方式传参的 * * @author holly * @date 2020/8/20 */ public class RequestParamContext { private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); /** * 保存请求参数 * * @author holly * @date 2020/6/21 20:17 */ public static void set(Dict requestParam) { CONTEXT_HOLDER.set(requestParam); } /** * 保存请求参数 * * @author holly * @date 2020/6/21 20:17 */ public static void setObject(Object requestParam) { if (requestParam == null) { return; } if (requestParam instanceof Dict) { CONTEXT_HOLDER.set((Dict) requestParam); } else { CONTEXT_HOLDER.set(Dict.parse(requestParam)); } } /** * 获取请求参数 * * @author holly * @date 2020/6/21 20:17 */ public static Dict get() { return CONTEXT_HOLDER.get(); } /** * 清除请求参数 * * @author holly * @date 2020/6/21 20:17 */ public static void clear() { CONTEXT_HOLDER.remove(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy