spring获取session设置session

2021-04-02 13:28

阅读:485

标签:htm   text   charset   log   用户   tps   return   class   attr   

获取session,设置session
@RequestMapping(value = "/loginUser", produces = {"text/html;charset=utf-8"}, method = RequestMethod.POST) public String login(@RequestParam(value = "user", required = false) String user, @RequestParam(value = "password") String password, @RequestParam(value = "telephone") String telephone, HttpSession session) { 。。。。。。省略一大段代码 //这里设置一下session,保存登录的用户信息到session中去 session.setAttribute("user",userDO); } 获取session。 /** * 登录的时候进到主页面 * @return */ @RequestMapping("/") public ModelAndView requestMapping(HttpSession session) { ModelAndView map = new ModelAndView("index"); System.out.println(session.getAttribute("user")); userMapper userMapper = (userMapper)session.getAttribute("user"); if(userMapper!=null) map.addObject("userid", userMapper.getUserid()); return map; }

spring获取session设置session

标签:htm   text   charset   log   用户   tps   return   class   attr   

原文地址:https://www.cnblogs.com/king0207/p/13490190.html


评论


亲,登录后才可以留言!