I have a project based in Spring Web model-view-controller (MVC) framework. The version of the Spring Web model-view-controller (MVC) framework is 3.2.8
I have this controller
@SuppressWarnings("unchecked")
@RequestMapping(value = { "/books/store/product",
"/books/store/product/",
"/books/store/product/{productId}",
"/books/store/product/{productId}/" }, method = { RequestMethod.POST })
public String saveProduct(@ModelAttribute("productForm") ProductForm productForm,
@PathVariable Long productId,
HttpServletRequest request, Model model) throws Exception {
..
}
Everything is fine for this URL : /books/store/product/232
but for this one /books/store/product/
I got this error:
Error 400--Bad Request
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.1 400 Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
I've tried to put this @PathVariable(required = false), but I got a compilation error: The attribute required is undefined for the annotation type PathVariable