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");
    }
posted @ 2024-02-04 17:31  CharyGao  阅读(149)  评论(0编辑  收藏  举报