Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring web: Controllers with annotated mappings - Getting HttpServletRequest / form data

I have a controller mapped using annotations; the URL is being accessed by the client app and it sends POST / GET data. How do I access the request object in this method?

like image 817
Sri Avatar asked Apr 09 '10 03:04

Sri


1 Answers

Just add an argument of type HttpServletRequest to the method.

Check 13.11.4. Supported handler method arguments and return types in the spring mvc docs

so:

public String yourMethod(HttpServletRequest request) {..}

You can use specific request parameters the following way:

public String yourMethod(@RequestParam("petId") int petId) {..}
like image 107
Bozho Avatar answered Sep 27 '22 17:09

Bozho