菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
428
0

[org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'xxx ' is not present]

原创
05/13 14:22
阅读数 62646

1、Spring Boot项目,发起Post请求,解决Required String parameter xxx is not present类型异常。

1 2021-03-29 08:43:52 - [http-nio-8082-exec-1] - WARN  - o.s.w.s.m.support.DefaultHandlerExceptionResolver - Resolved [org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'xxx ' is not present]
2 2021-03-29 08:43:52 - [http-nio-8082-exec-1] - DEBUG - org.springframework.web.servlet.DispatcherServlet - Completed 400 BAD_REQUEST
3 2021-03-29 08:43:52 - [http-nio-8082-exec-1] - DEBUG - org.springframework.web.servlet.DispatcherServlet - "ERROR" dispatch for POST "/error", parameters={masked}
4 2021-03-29 08:43:52 - [http-nio-8082-exec-1] - DEBUG - o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest)
5 2021-03-29 08:43:52 - [http-nio-8082-exec-1] - DEBUG - o.s.w.s.m.m.annotation.HttpEntityMethodProcessor - Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
6 2021-03-29 08:43:52 - [http-nio-8082-exec-1] - DEBUG - o.s.w.s.m.m.annotation.HttpEntityMethodProcessor - Writing [{timestamp=Mon Mar 29 20:43:52 CST 2021, status=400, error=Bad Request, message=, path=/api/offlineE (truncated)...]
7 2021-03-29 08:43:52 - [http-nio-8082-exec-1] - DEBUG - org.springframework.web.servlet.DispatcherServlet - Exiting from "ERROR" dispatch, status 400

其实,这个错误九成的原因,就是请求参数和@RequestParam(value = "userName ", required = true) String userName,注解@RequestParam的value值不一样的,我写的就奇葩了,字符串后面加了空格。

 

发表评论

0/200
428 点赞
0 评论
收藏