@Controller public class LoginController{ private HttpSession session; @RequestMapping("/login"); public String login(){ session.setAttribute("name","zhangshan"); ... } }
B.
@Controller public class LoginController{ @RequestMapping("/login"); public String login(){ HttpSession session; session.setAttribute("name","zhangshan"); ... } }
C.
@Controller public class LoginController{ @RequestMapping("/login"); public String login(HttpSession session){ session.setAttribute("name","zhangshan"); ... } }
D.
@Controller public class LoginController{ @RequestMapping("/login"); public String login(){ session.setAttribute("name","zhangshan"); ... } }