diff --git a/src/main/java/cn/chjyj/szwh/controller/BaseController.java b/src/main/java/cn/chjyj/szwh/controller/BaseController.java index 433be26..9b8bef7 100644 --- a/src/main/java/cn/chjyj/szwh/controller/BaseController.java +++ b/src/main/java/cn/chjyj/szwh/controller/BaseController.java @@ -1,11 +1,36 @@ package cn.chjyj.szwh.controller; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Objects; /** * 基础控制器 */ public abstract class BaseController { + public static Log log = LogFactory.getLog(BaseController.class); // jsonobject 全局 protected JSONObject jsonObject=new JSONObject(); + + static { + RequestAttributes ra = RequestContextHolder.getRequestAttributes(); + if(Objects.isNull(ra)){ + log.debug("服务里RequestAttributes对象为空"); + }else{ + ServletRequestAttributes sra = (ServletRequestAttributes) ra; + HttpServletRequest request = sra.getRequest(); + // 查询请求头中的token + String token=request.getHeader("token"); + // 查询头部中的模块 + final String url=request.getHeader("url"); + } + + } + }