i hav created a jsp page from which i m taking some values and on submit it should pass the parameters to the java class using rest.
< form id=”payment” method=”post” action=”addtogroup”>
< ol style=”padding: 0;”>
< li>< label for=”groupId”>Group id:< /label>
< input type=”text” id=”groupId” name=”groupId”/>
< br />
< li>< label for=”vendorId”>Profile Id :< /label>
< input type=”text” id=”vendorId” name=”vendorId”/>
< li>
< input type=”submit” value=”Submit”/>< br />
< /ol>
< /form>
and the java code is:
@RequestMapping(value = “/addtogroup/{groupId}/{vendorId}”,method = RequestMethod.POST)
public String addtoGroup(@ModelAttribute("groupId") String groupId,@ModelAttribute("vendorId") String profileId){
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth.getName();
System.out.println("group id is="+groupId);
System.out.println("profileId is="+profileId);
System.out.println("username is="+username);
grpDao.addToGroup(groupId,profileId,username);
return "addtogroup";
}
when i type [http://localhost:8080/biznex/rest/addtogroup/2/13] in the address bar directly the code is executed.
but when i click submit button in the jsp i get page not found error.
plz help me out.
< form id="payment" method="post" action="addtogroup">This statement means submit the FORM data using POST method to the url “currentpath”/”addtogroup”However, your RESTFUL Server side component expects the url in the form of
/addtogoup/{groupid}/{vendorid}in a GET methodI would suggest you to have a JavaScript method which converts your form fields to the URI path- using jQuery or plain JavaScript