关于JSP里的Java语句嵌入问题

是这样的,我用的是Intellij 导入了一个MyEclipse的包(该包已部署在服务器上,所以是没有大错误的)。

然后在一个jsp文件出现了个问题:

https://img.mukewang.com/5cb7ea0a0001c0d907450417.jpg

莫名奇妙地println变成了红色,执行的时候就直接抛出异常了。
今天刚接触JavaWeb不太懂,到底是怎么回事呢?

异常:

type Exception report


message An exception occurred processing JSP page /blackphones.jsp at line 15


description The server encountered an internal error that prevented it from fulfilling this request.


exception


org.apache.jasper.JasperException: An exception occurred processing JSP page /blackphones.jsp at line 15


12: <%

13:     String [] phones = (String []) request.getAttribute("blackphones");

14: 

15:     out.println("褰撳墠鏈� + phones.length + "涓墜鏈哄彿鐮侊細<br/><br/>");

16:     

17:     for(String phone : phones){

18:         out.println(phone + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");



Stacktrace:

    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:575)

    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)

    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)

    com.aspire.mmlite.server.servlet.LogFilter.doFilter(LogFilter.java:63)

root cause


java.lang.NullPointerException

    org.apache.jsp.blackphones_jsp._jspService(blackphones_jsp.java:96)

    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:439)

    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)

    com.aspire.mmlite.server.servlet.LogFilter.doFilter(LogFilter.java:63)


哈士奇WWW
浏览 430回答 2
2回答

潇湘沐

字符串数组没有实例化一个大小给它~length属性是空的

largeQ

鼠标移动到红色代码上看看提示什么?
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java