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;
    }

 

你可能感兴趣的:(java后台方法从cookie中获取部门编码)