无法将前端数据(AngularJS)发送到后端(Spring)

时间:2017-11-06 13:24:35

标签: angularjs spring

前端

var req = {
    method : 'GET',
    url : 'http://171.10.13.24:8989/SpringMvcJdbcTemplate/editContact',
    headers : {
        'Content-Type' : undefined
    },
    params : {
        id : $scope.user.id
    }
}

$http(req).then(function(responce) {
    // success function
    alert("success");
}, function(responce) {
    // Failure Function
});

这是发送请求的角度代码。

返回端:

@RequestMapping(value = "/editContact", method = RequestMethod.GET)
public ModelAndView editContact(HttpServletRequest request) {
    int contactId = Integer.parseInt(request.getParameter("id"));
    Contact contact = contactDAO.get(contactId);
    ModelAndView model = new ModelAndView("ContactForm");
    model.addObject("contact", contact);
    return model;
}

0 个答案:

没有答案