JSP页面上获取servlet里面值的问题
servlet中:List<VistSite>accounts=newArrayList<VistSite>();System.out.print("!!!"+accou...
servlet中:List<VistSite> accounts = new ArrayList<VistSite>();
System.out.print("!!!"+accounts.size());//能正确输出大小
JSP中: List<VistSite> VistSites=(List<VistSite>)request.getAttribute("accounts");
System.out.print( VistSites.size()); //出错
下面是
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
root cause
java.lang.NullPointerException
org.apache.jsp.Search_jsp._jspService(Search_jsp.java:179)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723) 展开
System.out.print("!!!"+accounts.size());//能正确输出大小
JSP中: List<VistSite> VistSites=(List<VistSite>)request.getAttribute("accounts");
System.out.print( VistSites.size()); //出错
下面是
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
root cause
java.lang.NullPointerException
org.apache.jsp.Search_jsp._jspService(Search_jsp.java:179)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723) 展开
2个回答
2016-01-08 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
JSP页面上获取servlet 的传值:
在Servlet中使用request.setAttribute("name",value);
RequestDispatcher rd=request.getRequestDispatcher("跳转的页面");
rd.forward(request,response);
在JSP页面中取得值写法:<%=request.setAttribute("name")%>
在Servlet中使用request.setAttribute("name",value);
RequestDispatcher rd=request.getRequestDispatcher("跳转的页面");
rd.forward(request,response);
在JSP页面中取得值写法:<%=request.setAttribute("name")%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询