In the Spring MVC controller i am trying to access the name sent by the JQuery simple post.
I am getting error Could not find @PathVariable [name] in @RequestMapping*
Where i am going wrong?
JQuery Post
$.post("addName.htm",{ name: "John"});
Spring Controller
@RequestMapping(value = "/addName.htm", method = RequestMethod.POST)
public void setAllocations(@PathVariable String name) {
System.out.println("inside Setting value.... ");
System.out.println(name);
}
I am getting error
Could not find @PathVariable [name] in @RequestMapping
That is not a
@PathVariable, you have to use a@RequestParaminstead. Try this:This is the difference:
http://yourhost/{name}/addName.htmlhttp://yourhost/addName.html?name={name}