Spring MVC
可以直接作为Controller的参数传入:
@RequestMapping(value = "/test", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody public Maptest(HttpSession session, String otherParam) { //TODO return null; }
其它
要获取HttpSession,只需要获取到HttpServletRequest,然后调用HttpServletRequest的getSession方法
1、注解自动注入
@Autowired private HttpSession session; @Autowired private HttpServletRequest request;
2、普通类中获取
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); request.getSession();
标签: httpsession、httpservletrequest、getsession、request、autowired
笔试题
刷题
简历模板
AI算法
大数据
内推
内推: