Im new to Spring MVC and trying to achive something that seems really simple. However i cannot get it to work or find any relevant examples.
Using Spring MCV 3.1 with annotations. I have a form with only one select-list in it. When this form is submitted, i want to be able to have the id of the select-value submitted to my controller. Thats it!
I dont want to wrap this value in a Binding object, i'd just like to send it to the controller, preferably by get like this: http://www.mydomain.com/admin/products?marketId=id
My Controller looks like this:
@RequestMapping(value = "/admin/products", method = RequestMethod.GET)
public ModelAndView getProducts(@RequestParam("marketId") String marketId) {
ModelMap model = new ModelMap();
// Logic to find products by marketId is not shown
// ...
model.addAttribute("products", products);
return new ModelAndView("products", model);
}
I have not been able to create a jsp that compiles yet, but this is my latest jsp snippet:
<form:form method="GET" action="/admin/products.htms" methodParam="marketId" >
<form:select path="marketId" items="${marketList}" onchange="this.form.submit();"/>
</form:form>
If anyone could help or point out some relevant examples i would be very grateful! I have looked at a lot of examples using a binding object to wrap the form-data, but as you can see im looking for something a bit simpler.
Cheers!