开发者社区> 问答> 正文

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

"

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

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

莫名奇妙地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 + "     ");


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)
" ![image.png](https://ucc.alicdn.com/pic/developer-ecology/173a5cf3a91146c0b36e7108a7cfb9a6.png)

展开
收起
因为相信,所以看见。 2020-05-26 13:56:06 534 0
1 条回答
写回答
取消 提交回答
  • 阿里,我所有的向往

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

    ######

    鼠标移动到红色代码上看看提示什么?

    ![image.png](https://ucc.alicdn.com/pic/developer-ecology/2c0a541690db48eaa1b5b349d1891264.png)
    2020-05-27 10:17:10
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载