jsp页面ArrayList数据错误…求救求救啊啊,困扰几天了…



<%
ArrayList viewFile = (ArrayList)session.getAttribute("viewFile");
ArrayList storyFile = (ArrayList)session.getAttribute("storyFile");
ArrayList creativeFile = (ArrayList)session.getAttribute("creativeFile");
ArrayList varietyFile = (ArrayList)session.getAttribute("varietyFile");
%>
……
    <table border="0" width="680px">
            <tr bgcolor="#FF9900">
                <td colspan="3"><%=viewFile.get(0).fileType.getFileTypeName()%></td>
                <td align="right"><a href="FileListServlet?biaoshi=wu&typeId=1">更多>></a></td>
            </tr>
            <tr>
            <%
                for(int i=0;i<viewFile.size();i++){
                    FileInfo file = viewFile.get(i);
            %>
                <td>
                    <table border="0" align="center">
                        <tr>
                            <td align="center">
                                <a href="showFileInfo.jsp?jihe=viewFile&id=<%=file.getFileId()%>">
                                <img src="uploadfiles/<%=file.getPic1() %>" width="150" height="180" border="0"/>
                                </a>
                            </td>

                        </tr>
                        <tr>
                            <td>
                              <a href="showFileInfo.jsp?jihe=viewFile&id=<%=file.getFileId()%>">
                                <%=file.getFileTitle() %>
                               </a>
                            </td>

                        </tr>

                    </table>
                </td>   
            <%
                }
             %> 
            </tr>

……
……

 ***结果:***

//<%=viewFile.get(0).fileType.getFileTypeName()%>这句报错,里面viewFile就是ArrayList
类型的…有ArrayList的页面就有错误…

org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
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:717)
root cause

java.lang.NullPointerException
org.apache.jsp.show_jsp._jspService(show_jsp.java:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
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:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.

2个回答

查查相应的servlet里有没有写绑定名称为viewFile的session,还有转发的语句有写吗?

<%=viewFile.get(0).getFileTypeName()%>或者先强制类型转换一下

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐