前端
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;
}