protected void selectArtclesByVagueType(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int VagueTypeId = 1;
if(request.getParameter("VagueTypeId") != null){
VagueTypeId = Integer.parseInt(request.getParameter("VagueTypeId"));
}
List<Artcle> ArtcleList = artcleBIZImp.selectArtclesByVagueType(VagueTypeId);
List<User> userList = new ArrayList<User>();
for(int i = 0;i<ArtcleList.size();i++){
try {
User user = userBIZImp.selectUserByUserId(ArtcleList.get(i).getUser().getUserId());
userList.add(user);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
List<Object> list = new ArrayList<Object>();
list.add(ArtcleList);
list.add(userList);
request.setAttribute("list",list);
request.getRequestDispatcher("index.jsp").forward(request, response);
}
如果直接使用
${list.ArtcleList.值}
${list.userList.值}
的方式取值会报错,报错信息如下
严重: Servlet.service() for servlet ArtcleActionServlet threw exception
java.lang.NumberFormatException: For input string: "ArtcleList"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:447)
at java.lang.Integer.parseInt(Integer.java:497)
at javax.el.ListELResolver.coerce(ListELResolver.java:166)
at javax.el.ListELResolver.getValue(ListELResolver.java:51)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.el.parser.AstValue.getValue(AstValue.java:123)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:182)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:919)
at org.apache.jsp.index_jsp._jspx_meth_c_005fforEach_005f0(index_jsp.java:1218)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:760)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at com.takun.action.ArtcleActionServlet.selectArtclesByVagueType(ArtcleActionServlet.java:65)
at com.takun.action.ArtcleActionServlet.service(ArtcleActionServlet.java:31)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)