Here is my jquery ajax ajax request
$.ajax({
url: "/some_url",
type: "GET",
contentType : "application/json; charset=utf-8",
async: false,
data: {"attribute_1":"some_value_1","attribute_2":"some_value_2"};,
cache: false,
success: function(response) {}
});
Here is my controller method
@RequestMapping(value = "/some_url", method = { RequestMethod.GET })
public String getDetails(HttpServletRequest request,@RequestBody CustomDTO customDTO) {
}
But request does not reach controller method and get 404 error ? If I make it post at ajax and controller level it works. I understand @RequestBody
works with POST
request only.
My question how can i map the input request parameters to domain object in ajax GET
request under spring mvc ?
Do I have do define each parameter as getDetails(HttpServletRequest request,@RequestParam String pName1, @RequestParam String pName2,...)
as defined at
How to pass Json object from ajax to spring mvc controller? or is there a cleaner way to wrap them in domain object