您正在将地图作为请求参数发送。您正在尝试在请求正文中阅读它。那可能行不通。无论如何,GET请求都没有主体。
这是您应该如何做:
var parameters = {};parameters.name = skills.skillName;parameters.month = skills.expMonth;parameters.year = skills.expYear;parameters.experties = skills.experties;var promise = $http.get('/JobSearch/user/addskill', { params: parameters});
在Spring控制器中:
@RequestMapping(value = "/addskill", method = RequestMethod.GET)@ResponseStatus(value = HttpStatus.NO_CONTENT)public void addStudentSkill(@RequestParam("name") String name, @RequestParam("name") String month, @RequestParam("name") String year, @RequestParam("name") String experties) { ...}
就是说,给定方法的名称
addStudentSkill以及它不返回任何内容的事实,似乎此方法不是用于从服务器获取数据,而是用于在服务器上创建数据。因此,此方法应映射到POST请求,并且数据应作为正文发送:
var data = {};data.name = skills.skillName;data.month = skills.expMonth;data.year = skills.expYear;data.experties = skills.experties;var promise = $http.post('/JobSearch/user/addskill', params);
并在控制器中:
@RequestMapping(value = "/addskill", method = RequestMethod.POST)@ResponseStatus(value = HttpStatus.CREATED)public void addStudentSkill(@RequestBody Map<String, String> data) { ...}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)