lass org.springframework.beans.BeanWrapperImpl can not access a member of class org.test.User with m
在使用springmvc开发时代码中出现如下错误,解决方法如下
aused by: org.springframework.beans.InvalidPropertyException: Invalid property 'userList[0]' of bean class [org.test.User]: Illegal attempt to get property 'userList' threw exception; nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'userList' of bean class [org.test.User]: Could not instantiate property type [org.test.User] to auto-grow nested property path: java.lang.IllegalAccessException: Class org.springframework.beans.BeanWrapperImpl can not access a member of class org.test.User with modifiers "private"
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:827)
at org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:554)
at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:531)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:892)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:740)
at org.springframework.validation.DataBinder.doBind(DataBinder.java:636)
at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:191)
at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:112)
at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.bindRequestParameters(ServletModelAttributeMethodProcessor.java:153)
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:106)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:123)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
... 41 more
Caused by: org.springframework.beans.NullValueInNestedPathException: Invalid property 'userList' of bean class [org.test.User]: Could not instantiate property type [org.test.User] to auto-grow nested property path: java.lang.IllegalAccessException: Class org.springframework.beans.BeanWrapperImpl can not access a member of class org.test.User with modifiers "private"
at org.springframework.beans.BeanWrapperImpl.newValue(BeanWrapperImpl.java:633)
at org.springframework.beans.BeanWrapperImpl.growCollectionIfNecessary(BeanWrapperImpl.java:865)
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:770)
... 59 more
通过上述错误发现User这个类不允许被访问,查看了一下代码原来是自己把构造函数写成了private 导致不能解析
解决方法把私有的构造函数改成public
原来private User() {} 修改成public User() {}
- 解决 org.mybatis.spring.MyBatisSystemException: ne
- 解决 Exception in thread "main" java.lang.Illega
- 解决 WebSocketHandlerMapping#0': Cannot resolve r
- java spring后台如何解决跨域请求 No 'Access-Contro
- spring 配置事务不起作用原因 service层事务无效
- spring mvc 获取HttpServletRequest HttpServletRespo
- Cause: org.xml.sax.SAXParseException: The content
- 解决 Caused by: org.springframework.beans.BeanInst
- javax.net.ssl.SSLException: java.lang.RuntimeExcep
- springmvc csv文件导出_csv文件下载_csv文件生成