put请求参数必须加@RequestBody
put请求时,参数映射成实体类时,必须加@RequestBody,否则接收不到参数
//修改字典
@RequestMapping(value = "dict",method=RequestMethod.PUT,produces="application/json;charset=UTF-8")
@ResponseBody
public Object modifyDict(HttpServletRequest request,HttpServletResponse response,
@RequestBody Dict dict) {
if(dict.getId()==null){
return ErrInfoUtils.errInfo(2, "Update the id is null");
}
try {
dictService.updateDictByPrimaryKey(dict);
} catch (Exception e) {
e.printStackTrace();
return ErrInfoUtils.errInfo(1, "error");
}
return ErrInfoUtils.errInfo(0, "OK");
}
摘抄自网络,便于检索查找。