java后端接受Vue传递的List
Failed to resolve argument 1 of type 'java.util.List'
org.springframework.web.bind.MissingServletRequestParameterException: Required List parameter 'categories' is not present
at org.hod.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:204) ~ [spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at
org.hod.solveArgument(AbstractNamedValueMethodArgumentResolver.java:112) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.hod.solveArgument(HandlerMethodArgumentResolverComposite.java:124) ~ [spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.hod.MethodArgumentValues(InvocableHandlerMethod.java:161) [spring-web-
5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.hod.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:131) [spring-web-
5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.web.hod.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) [spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.web.hod.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) [spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.web.hod.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) [spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.web.hod.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) [spring-webmvc-
springframework jar包下载5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) [spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) [spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) [spring-webmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877) [spring-we
bmvc-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) [tomcat-embed-core-8.5.29.jar:8.5.29]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) [spring-webmvc-5.
原因是前端传递的是两个参数,造成后台没有办法解析(如下图
有两个categories的数组
原来代码是data: this.$qs.stringify(this.brand) 修改成 data: this.$qs.stringify(this.brand, { indices: false })
或者是qs.stringify({ids: [1, 2, 3]}, {arrayFormat: ‘repeat‘})
详细可以转换数组查看,
,⾥⾯有详细的解析
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论