admin管理员组文章数量:1387360
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);
版权声明:本文标题:javascript - how to call the spring controller method from form using java script or Jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744553208a2612312.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论