at org.apache.jsp.index_jsp._jspInit(index_jsp.java:23)

环境:Tomcat6 + jdk6

Tomcat服务启动成功,但访问index.jsp出错,Tomcat报错如下:

严重: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
    at org.apache.jsp.index_jsp._jspInit(index_jsp.java:23)
    at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
    at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
    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:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    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:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
    at java.lang.Thread.run(Thread.java:619)

 

最后找到原因:jsp-api.jar冲突。

jsp-api.jar冲突会造成jsp页面无法解析。

写自定义标签的时候请注意,在工程编译的时候可以引用jsp-api.jar,但发布的时候工程不要包含此包,因为Tomcat已包含。

 

用于开发,而不用于发布

解决方法1:User Library

选中项目-->右击-->properties-->Java Build Path --> Add Library --> 选中 User Liberary -->

Next --> User Libraries... --> New -->如下一定要选中:口 System Library.... (作为系统库像JDK一样)


--> Add Jars -->导入 与Tomcat冲突jar --> 选中jsp-jar OK

解决方法2:修改配置

打开项目目录,编辑.classpath文件

将:<classpathentry kind="lib" path="/............/jsp-jar"/>

改:<classpathentry kind="con" path="/............/jsp-jar"/>

刷新项目OK

 

结果导入的jar包显示为系统库:


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值