Hai i tried calling the controller using
document.forms[0].value = "getSignFaces";
document.forms[0].submit();
But its not calling method in controller
@RequestMapping(value=signFaces.do, method=RequestMethod.POST , params ="getSignFaces")
public String getSignFaces(Model model,@ModelAttribute(HBMSWebConstants.MODEL_SIGN_DETAILS) HBMSSessionDataWO sessionData,
@ModelAttribute SignDetailsForm form,HttpServletRequest request,
HttpServletResponse response,@RequestParam String noOfFaces,
I need to send the noOfFaces to this method.
Some how it is failling. Please let me know if i am missing any thing
Hai i tried calling the controller using
document.forms[0].value = "getSignFaces";
document.forms[0].submit();
But its not calling method in controller
@RequestMapping(value=signFaces.do, method=RequestMethod.POST , params ="getSignFaces")
public String getSignFaces(Model model,@ModelAttribute(HBMSWebConstants.MODEL_SIGN_DETAILS) HBMSSessionDataWO sessionData,
@ModelAttribute SignDetailsForm form,HttpServletRequest request,
HttpServletResponse response,@RequestParam String noOfFaces,
I need to send the noOfFaces to this method.
Some how it is failling. Please let me know if i am missing any thing
Share Improve this question edited Jun 26, 2014 at 14:47 secretformula 6,4324 gold badges34 silver badges56 bronze badges asked Jun 26, 2014 at 13:50 user2593318user2593318 351 gold badge2 silver badges7 bronze badges 01 Answer
Reset to default 2I think you can try using an ajax call to do the post to the controller.
as an example:
var jsonfile= {json:JSON.stringify(contents)};
$.ajax({
type:'POST',
url: "/yourcontrollermapping/signFaces.do
data: jsonfile,
dataType: "json"
});
and then your controller method:
@Controller
@RequestMapping("/yourcontrollermapping"
public class YourController(){
@RequestMapping(value = "/signFaces.do, method = RequestMethod.POST)
public void getSignFaces(@RequestParam("json) String json){
//stuff you want to do
}
}
If you wanne do it javascript native you can :
var jsonfile= {json:JSON.stringify(contents)};
var r = new XMLHttpRequest(); r.open("POST", "yourcontrollermapping/signFaces.do", true); r.onreadystatechange = function () { if (r.readyState != 4 || r.status != 200) return; console.log(r.responseText); }; r.send(jsonFile);