Reputation: 777
I need to take two parameters in my spring controller.
http://mydomain.com/myapp/getDetails?Id=13&subId=431
I have controller which will return Json for this request.
@RequestMapping(value = "/getDetails", method = RequestMethod.GET,params = "id,subId", produces="application/json")
@ResponseBody
public MyBean getsubIds(@RequestParam String id, @RequestParam String subId) {
return MyBean
}
I am getting 400 for when i tried to invoke the URL. Any thoughts on this? I was able to get it with one parameter.
Upvotes: 0
Views: 516
Reputation: 1757
As for me it works (by calling: http://www.example.com/getDetails?id=10&subId=15):
@RequestMapping(value = "/getDetails", method = RequestMethod.GET, produces="application/json")
@ResponseBody
public MyBean getsubIds(@RequestParam("id") String id, @RequestParam("subId") String subId) {
return new MyBean();
}
P.S. Assuming you have class MyBean.
Upvotes: 1
Reputation: 35598
Try specifying which parameter in the query string should match the parameter in the method like so:
public MyBean getsubIds(@RequestParam("id") String id, @RequestParam("subId") String subId) {
If the code is being compiled without the parameter names, Spring can have trouble figuring out which is which.
Upvotes: 2