javax.el.PropertyNotFoundException:Property';用户名';在类型java.lang.String上找不到

javax.el.PropertyNotFoundException:Property';用户名';在类型java.lang.String上找不到,java,spring-boot,spring-mvc,jsp,Java,Spring Boot,Spring Mvc,Jsp,我已包括所有必要的,但不知道为什么会有错误原因plz帮助我 我的型号是: Entity @Table(name = "user") public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String username; private String mobileno; private String pas

我已包括所有必要的,但不知道为什么会有错误原因plz帮助我

我的型号是:

Entity
@Table(name = "user")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private String username;

    private String mobileno;

    private String password;
    private String passwordConfirm;
@Controller
public class AdminController {
    @Autowired
    private UserValidator userValidator;

    @Autowired
    private UserService userService;

    @Autowired
    private SecurityService securityService;

    @RequestMapping(value = "/list-user", method = RequestMethod.GET)
    public ModelAndView DisplayUser(ModelAndView mv) {
        mv.addObject("userlist",userService.getallUsers());
        mv.setViewName("list-user");
        return mv;
    }
}
包括所有的getter setter

我的控制器:

Entity
@Table(name = "user")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private String username;

    private String mobileno;

    private String password;
    private String passwordConfirm;
@Controller
public class AdminController {
    @Autowired
    private UserValidator userValidator;

    @Autowired
    private UserService userService;

    @Autowired
    private SecurityService securityService;

    @RequestMapping(value = "/list-user", method = RequestMethod.GET)
    public ModelAndView DisplayUser(ModelAndView mv) {
        mv.addObject("userlist",userService.getallUsers());
        mv.setViewName("list-user");
        return mv;
    }
}
我的jsp页面

          <div class="row">

        <!-- main contain here -->

           <h1>List of Users</h1>
           <table>
           <thead>
           <tr>
           <th>Name</th>
           <th>Phone no</th>
           <th>Password</th>               
           </tr>
           </thead>
           <c:forEach items="${userlist} " var="user">
          <tbody>                        
           <td><c:out value=${user.username }></c:out></td>
           <td>${user.mobileno }</td>
           <td>${user.password }</td>
           </tbody>
           </c:forEach>             


           </table>




      <!-- Content Row -->



    <!-- /.container-fluid -->

  </div>
Stacktrace:]具有根本原因

javax.el.PropertyNotFoundException: Property 'username' not found on type java.lang.String
    at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:268) ~[tomcat-embed-el-8.0.33.jar:8.0.33]
    at javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:221) ~[tomcat-embed-el-8.0.33.jar:8.0.33]
    at javax.el.BeanELResolver.property(BeanELResolver.java:355) ~[tomcat-embed-el-8.0.33.jar:8.0.33]
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:95) ~[tomcat-embed-el-8.0.33.jar:8.0.33]
    at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110) ~[tomcat-embed-jasper-8.0.33.jar:8.0.33]
    at org.apache.el.parser.AstValue.getValue(AstValue.java:169) ~[tomcat-embed-el-8.0.33.jar:8.0.33]
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184) ~[tomcat-embed-el-8.0.33.jar:8.0.33]
    at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:943) ~[tomcat-embed-jasper-8.0.33.jar:8.0.33]
    at org.apache.jsp.list_002duser_jsp._jspx_meth_c_005fforEach_005f0(list_002duser_jsp.java:478) ~[na:na]
    at org.apache.jsp.list_002duser_jsp._jspService(list_002duser_jsp.java:355) ~[na:na]
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) ~[tomcat-embed-jasper-8.0.33.jar:8.0.33]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438) ~[tomcat-embed-jasper-8.0.33.jar:8.0.33]
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) ~[tomcat-embed-jasper-8.0.33.jar:8.0.33]
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) ~[tomcat-embed-jasper-8.0.33.jar:8.0.33]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.0.33.jar:8.0.33]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:69) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:68) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:184) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application

请检查下面的方法是否返回任何值

userService.getallUsers()

然后,尝试使用
addAttribute()
而不是
addObject()

如果仍然存在任何问题,请尝试用以下代码替换控制器方法

public String DisplayUser(ModelMap map) {
    map.addObject("userlist",userService.getallUsers());
    return "list-user";
}

如果仍然存在任何问题,请参考此

用户服务.getallUsers()是什么样子的?向我们展示您的
用户服务,getallUsers()
method@Overridepublic List getallUsers(){return userRepository.findAll();}javax.el.MethodNotFoundException:找不到方法:class java.lang.String.getUsername()对于前面的回答,很抱歉,您已经放置了正确的JSP代码。我更新了我的答案,请尝试一下。