Required request body is missing:415

简介: Required request body is missing:415

今天在做项目的时候遇到了,测试数据出现这个日志打印,而后台一postman一直也在跟我发415的请求


6d3ac2665d124658b872c864034b9428.png

{
    "timestamp": "2022-10-18T14:09:14.853+0000",
    "status": 415,
    "error": "Unsupported Media Type",
    "message": "Content type 'text/plain;charset=UTF-8' not supported",
    "path": "/product/brand/save"
}

请求的主题内容不存在的错误

816acfbee59f41908426ff056b02d539.png

9f49d489ce794bf2a0c26105e44b9961.png


以Text发送引出来的


这个接口请求的方式是post ,请求的body应该以json的形式写到raw里面(postMan)


这个接口请求的方式是post ,请求的body应该以json的形式写到raw里面(postMan)


这个接口请求的方式是post ,请求的body应该以json的形式写到raw里面(postMan)


这个接口请求的方式是post ,请求的body应该以json的形式写到raw里面(postMan)


在后台方法参数上添加@RequestBody时,将请求参数封装成User对象时,需要JSON(application/json)格式  


d39787742776476cb39fcd0e8449cd3e.png

我的controller如下

   /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@Valid @RequestBody BrandEntity brand, BindingResult result){
        if(result.hasErrors()){
            //1.获取校验错误的结果
            Map<String, String> map = new HashMap<>();
            result.getFieldErrors().forEach((item)->{
           //FieldError获取到错误的提示
           String message = item.getDefaultMessage();
            //获取错误的属性的名字
           String field = item.getField();
           map.put(field,message);
           System.out.println("******");
       });
            return R.error(400,"提交的数据不合法").put("data",map);
        }else {
            brandService.save(brand);
            return R.ok();
        }
    }

在后台方法参数上添加@RequestBody时,将请求参数封装成User对象时,需要JSON(application/json)格式


相关文章
解决方案:Missing URI template variable ‘userName‘ for method parameter of type String
解决方案:Missing URI template variable ‘userName‘ for method parameter of type String
解决Missing cookie ‘JssionId‘ for method parameter of type String问题
解决Missing cookie ‘JssionId‘ for method parameter of type String问题
182 0
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
131 0
|
JSON 数据格式
axios.post请求出错:Request header field content-type is not allowed by Access-Control-Allow-Headers in……
axios.post请求出错:Request header field content-type is not allowed by Access-Control-Allow-Headers in……
request.getParameter、request.getParameterValues、request.getParameterMap用法
request.getParameter、request.getParameterValues、request.getParameterMap用法
152 0
|
人工智能 Java
Required request body is missing
Required request body is missing
224 0
|
JSON 数据格式
Required request parameter ‘name‘ for method parameter type String is not present 报错解决方法
Required request parameter ‘name‘ for method parameter type String is not present 报错解决方法
3791 0
|
前端开发 数据库
Failed to load response dataNo data found for resource with given identifier
Failed to load response dataNo data found for resource with given identifier
1699 0
HttpMessageNotReadableException: Required request body is missing: xxx.controller.login(xxx)...
HttpMessageNotReadableException: Required request body is missing: xxx.controller.login(xxx)...
HttpMessageNotReadableException: Required request body is missing: xxx.controller.login(xxx)...