只需要在控制器的方法参数定义HttpServletRequest和HttpServletResponse对象。
@RequestMapping("/testServlet") public String testServlet(HttpServletRequest request, HttpServletResponse response) { System.out.println("执行了。。。"); System.out.println(request); HttpSession session = request.getSession(); System.out.println(session); return "success"; }