Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在JSP EL中访问集合时出现NumberFormatException_Java_Jsp_Spring Mvc_Jakarta Ee_El - Fatal编程技术网

Java 在JSP EL中访问集合时出现NumberFormatException

Java 在JSP EL中访问集合时出现NumberFormatException,java,jsp,spring-mvc,jakarta-ee,el,Java,Jsp,Spring Mvc,Jakarta Ee,El,我使用的是SpringMVC,我想从jsp文件访问我的雇员的角色,但我有这个错误。 这是我的控制器和jsp文件以及我的实体: AdminStockController: @RequestMapping(value="/saveEmploye") public String enregistrerE(@Valid Employe e,BindingResult bindingResult,Model model, @RequestParam(value="roleEmploye") Long id

我使用的是SpringMVC,我想从jsp文件访问我的雇员的角色,但我有这个错误。 这是我的控制器和jsp文件以及我的实体:

AdminStockController:

@RequestMapping(value="/saveEmploye")
public String enregistrerE(@Valid Employe e,BindingResult bindingResult,Model model, @RequestParam(value="roleEmploye") Long idR){
    if(bindingResult.hasErrors()){
        model.addAttribute("employes", metier.getAllEmployes());
        return "adminEmploye";
    }   

       metier.addEmploye(e);
       metier.addRoleToEmploye(e.getIdEmploye(), idR);
       model.addAttribute("employe", new Employe());
       model.addAttribute("role", new Role());
       model.addAttribute("employes", metier.getAllEmployes());
       model.addAttribute("roles", metier.getAllRole());
    return "adminEmploye";

}
    <div id="listeEmploye">
    <table class="table table-striped">
    <tr>
    <th> CODE_EMPLOYE </th> <th> NOM COMPLET </th> <th> USER_NAME </th> <th> PASSWORD </th><th> ROLE </th>
</tr>
    <c:forEach items="${employes}" var="e">
    <tr>
    <td> ${e.idEmploye }</td>
    <td> ${e.nomComplet }</td>
    <td> ${e.username }</td>
    <td> ${e.password }</td>
    <td> ${e.roles.roleName}</td>
    <td> <a href="supprimerEmploye?id=${e.idEmploye}"> Supprimer </a> </td>
    </tr>
    </c:forEach>
    </table>
    </div>
adminEmploye.jsp:

@RequestMapping(value="/saveEmploye")
public String enregistrerE(@Valid Employe e,BindingResult bindingResult,Model model, @RequestParam(value="roleEmploye") Long idR){
    if(bindingResult.hasErrors()){
        model.addAttribute("employes", metier.getAllEmployes());
        return "adminEmploye";
    }   

       metier.addEmploye(e);
       metier.addRoleToEmploye(e.getIdEmploye(), idR);
       model.addAttribute("employe", new Employe());
       model.addAttribute("role", new Role());
       model.addAttribute("employes", metier.getAllEmployes());
       model.addAttribute("roles", metier.getAllRole());
    return "adminEmploye";

}
    <div id="listeEmploye">
    <table class="table table-striped">
    <tr>
    <th> CODE_EMPLOYE </th> <th> NOM COMPLET </th> <th> USER_NAME </th> <th> PASSWORD </th><th> ROLE </th>
</tr>
    <c:forEach items="${employes}" var="e">
    <tr>
    <td> ${e.idEmploye }</td>
    <td> ${e.nomComplet }</td>
    <td> ${e.username }</td>
    <td> ${e.password }</td>
    <td> ${e.roles.roleName}</td>
    <td> <a href="supprimerEmploye?id=${e.idEmploye}"> Supprimer </a> </td>
    </tr>
    </c:forEach>
    </table>
    </div>

代码\u员工姓名完成用户名密码角色
${e.idEmploye}
${e.nomplett}
${e.username}
${e.password}
${e.roles.roleName}
Employe.java:

 @Entity
    public class Employe implements Serializable{
        @Id
        @GeneratedValue(strategy=GenerationType.IDENTITY)
        private Long idEmploye;
        private String nomComplet;
        private String username;
        private String password;
        @Enumerated(EnumType.STRING)
        private EmployeStatus status;
        @ManyToMany( cascade={CascadeType.ALL})
        @JoinTable(name="EmployesAndRoles",
        joinColumns=@JoinColumn(name="employe_id"),
        inverseJoinColumns=@JoinColumn(name="role_id"))
        private Collection<Role> roles;
        @OneToMany(mappedBy="employe", fetch=FetchType.LAZY)
        private Collection<Commande> commandes;
        @OneToMany(mappedBy="employe", fetch=FetchType.LAZY)
        private Collection<Enregistrement> enregistrements;

    // + constructors + getters and setters
@Entity
public class Role implements Serializable{
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    private String roleName;
    @ManyToMany(mappedBy="roles")
    private Collection<Employe> employes;
// + constructors + getters and setters
@实体
公共类Employe实现可序列化{
@身份证
@GeneratedValue(策略=GenerationType.IDENTITY)
私人长期雇员;
私有字符串nomplete;
私有字符串用户名;
私有字符串密码;
@枚举(EnumType.STRING)
私人雇员身份;
@ManyToMany(cascade={CascadeType.ALL})
@JoinTable(name=“employeesandroles”,
joinColumns=@JoinColumn(name=“employe_id”),
inverseJoinColumns=@JoinColumn(name=“role\u id”))
私人收藏角色;
@OneToMany(mappedBy=“employe”,fetch=FetchType.LAZY)
私人收藏命令;
@OneToMany(mappedBy=“employe”,fetch=FetchType.LAZY)
私人收藏登记;
//+构造函数+getter和setter
Role.java:

 @Entity
    public class Employe implements Serializable{
        @Id
        @GeneratedValue(strategy=GenerationType.IDENTITY)
        private Long idEmploye;
        private String nomComplet;
        private String username;
        private String password;
        @Enumerated(EnumType.STRING)
        private EmployeStatus status;
        @ManyToMany( cascade={CascadeType.ALL})
        @JoinTable(name="EmployesAndRoles",
        joinColumns=@JoinColumn(name="employe_id"),
        inverseJoinColumns=@JoinColumn(name="role_id"))
        private Collection<Role> roles;
        @OneToMany(mappedBy="employe", fetch=FetchType.LAZY)
        private Collection<Commande> commandes;
        @OneToMany(mappedBy="employe", fetch=FetchType.LAZY)
        private Collection<Enregistrement> enregistrements;

    // + constructors + getters and setters
@Entity
public class Role implements Serializable{
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    private String roleName;
    @ManyToMany(mappedBy="roles")
    private Collection<Employe> employes;
// + constructors + getters and setters
@实体
公共类角色实现可序列化{
@身份证
@GeneratedValue(策略=GenerationType.IDENTITY)
私人长id;
私有字符串roleName;
@许多(mappedBy=“角色”)
私人收藏雇员;
//+构造函数+getter和setter
下面是错误:

org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/adminEmploye.jsp at line 49

46: <td> ${e.nomComplet }</td>
47: <td> ${e.username }</td>
48: <td> ${e.password }</td>
49: <td> ${e.roles.roleName}</td>
50: <td> <a href="supprimerEmploye?id=${e.idEmploye}"> Supprimer </a> </td>
51: </tr>
52: </c:forEach>


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
    org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
cause mère

java.lang.NumberFormatException: For input string: "roleName"
    java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    java.lang.Integer.parseInt(Integer.java:580)
    java.lang.Integer.parseInt(Integer.java:615)
    javax.el.ListELResolver.coerce(ListELResolver.java:163)
    javax.el.ListELResolver.getValue(ListELResolver.java:51)
    org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
    org.apache.el.parser.AstValue.getValue(AstValue.java:183)
    org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
    org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:944)
    org.apache.jsp.WEB_002dINF.views.adminEmploye_jsp._jspx_meth_c_005fforEach_005f0(adminEmploye_jsp.java:172)
    org.apache.jsp.WEB_002dINF.views.adminEmploye_jsp._jspService(adminEmploye_jsp.java:111)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
    org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
org.apache.jasper.JasperException:在第49行处理JSP页面/WEB-INF/views/adminEmploye.JSP时发生异常
46:${e.nomplett}
47:${e.username}
48:${e.password}
49:${e.roles.roleName}
50:   
51: 
52: 
堆栈跟踪:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javaservlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
javaservlet.http.HttpServlet.service(HttpServlet.java:624)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javaservlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.savedrequest.RequestCacheAwarRefilter.doFilter(RequestCacheAwarRefilter.java:45)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPer