Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we get HttpRequest Object in Controller in Spring MVC

Tags:

spring-mvc

Is it possible that I can get HttpRequest object in my Controller class in Spring MVC ?

@Controller
public class ContactController {

    @Autowired
    private ContactService contactService; 

    @RequestMapping("/login")
    public String displayLoginPage(@ModelAttribute("login") Login login, BindingResult result) {
        return "login";
    }
}
like image 833
Vaibhav Avatar asked Dec 02 '13 02:12

Vaibhav


1 Answers

@RequestMapping("/login")
public String displayLoginPage(HttpServletRequest request, @ModelAttribute("login") Login login, BindingResult result){
    return "login";
}
like image 130
Alex Avatar answered Jan 03 '23 12:01

Alex