后台获取session: @RequestMapping("/usrlogin") public ModelAndView usrlogin(@RequestParam String usrid, @RequestParam String passwd) { HttpSession session = getSession(); User user = new User(); user = userMapper.getUserByUsridAndPasswd(usrid, passwd
最近在ASP.NET MVC项目中碰到这样的情况:在一个controller中设置了Session,但在另一个controller的构造函数中无法获取该Session,会报"System.NullReferenceException"错误.之所以这样做是因为希望在controller构造函数中获取Session值并赋值给一个全局变量,好让该controller的多个action共享. 起先以为是ASP.NET State Service服务没有开启,或者是Web.config中sess
最近在ASP.NET MVC项目中碰到这样的情况:在一个controller中设置了Session,但在另一个controller的构造函数中无法获取该Session,会报"System.NullReferenceException"错误.之所以这样做是因为希望在controller构造函数中获取Session值并赋值给一个全局变量,好让该controller的多个action共享. 起先以为是ASP.NET State Service服务没有开启,或者是Web.config中sess