java后台方法从cookie中获取部门编码

    @RequestMapping(value = "/UpdateUser", method = RequestMethod.POST)
    @ResponseBody
    public String UpdateUser(@RequestBody String userStr, HttpServletRequest request) {

            String data = Utils.getJsonData(userStr);
            JSONObject json = (JSONObject) JSON.parse(data);
            String userId = json.getString("userId");//从cookie中获取部门编码
            Cookie[] cookies = request.getCookies();
            String deptCd = null;
            for(Cookie cookie:cookies){
                if(cookie.getName().equals("deptCd")){
                    deptCd = cookie.getValue();
                }
            }
            return null;
    }

 

posted @ 2020-06-03 10:33  表演给自己看的认真  阅读(253)  评论(0编辑  收藏  举报