在控制器中使用ServletAPI类型HttpSession,下列代码正确的是()
A.
@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"); ... } }