开发JSP,使用Eclipse(JDK1.5),部署WEB应用Tomcat5.0.29
请求JSP时,Tomcat日志显示“javac: 目标版本 1.3 与默认的源版本 1.5 冲突”
查看上面的错误日志,发现"compilerTargetVM=1.3",应该时Tomcat的JSP编译时使用的JDK1.3的版本。
进行如下修改:
找到tomcat conf目录下的web.xml,将这段内容:
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
改为如下
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.5</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.5</param-value>
</init-param>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>compiler</param-name>
<param-value>modern</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
重新启动Tomcat,问题解决