前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >[org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'xx

[org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'xx

作者头像
别先生
发布2021-04-09 15:37:49
2.9K0
发布2021-04-09 15:37:49
举报
文章被收录于专栏:别先生

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

代码语言:javascript
复制
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值不一样的,我写的就奇葩了,字符串后面加了空格。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-04-02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档