我可以在Spring MVC的Controller类中获取HttpRequest对象吗?
@Controller
public class ContactController {
@Autowired
private ContactService contactService;
@RequestMapping("/login")
public String displayLoginPage(@ModelAttribute("login") Login login, BindingResult result) {
return "login";
}
}
答案 0 :(得分:7)
@RequestMapping("/login")
public String displayLoginPage(HttpServletRequest request, @ModelAttribute("login") Login login, BindingResult result){
return "login";
}