Netbeans不会将JSP视为源级别7 [英] Netbeans will not treat JSP as Source Level 7

查看:165
本文介绍了Netbeans不会将JSP视为源级别7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行我创建的 .jsp 页面并继续遇到此错误:

I'm trying to run a .jsp page I made and keep encountering this error:


类型异常报告

type Exception report

消息内部服务器错误

描述服务器遇到内部错误这阻止了它完成此请求。

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

异常

org.apache.jasper.JasperException:PWC6033:错误在JSP的Javac编译中

org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6197:在jsp文件中的第27行发生错误:/Drupalcheck.jsp
PWC6199:生成的servlet错误:$ b -bource 1.5
不支持$ b菱形运算符(使用-source 7或更高版本启用菱形运算符)

PWC6197: An error occurred at line: 27 in the jsp file: /Drupalcheck.jsp PWC6199: Generated servlet error: diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)

注意异常的完整堆栈跟踪它的根本原因可以在GlassFish Server Open Source Edition 4.0日志中找到。

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.

问题是我不知道为什么我'得到它。我在JDK下将JDK设置为1.7,在源代码下将源/二进制格式设置为JDK 7.

The issue is that I have no clue why I'm getting it. I have the JDK set to 1.7 under Libraries and Source/Binary Format set to JDK 7 under sources.

我使用Netbeans作为我的IDE。

I am using Netbeans as my IDE.

我已经完成了从重新安装Java到重新安装Netbeans并且无处可去的所有事情。

I've done everything from reinstalling Java to reinstalling Netbeans and have gotten nowhere.

推荐答案

在我看来,这与Netbeans无关,而是与正在使用的应用服务器有关。怀疑你使用 Glassfish Tomcat ,因为它们与Netbeans 7捆绑在一起。

In my opinion this has nothing to do with Netbeans, but rather with the application server in use. Is suspect you're using Glassfish or Tomcat as they are bundled together with Netbeans 7.

我有与Apache Tomcat相同的问题,归结为Tomcat(Apache Jasper库)默认使用 Java 1.6进行JSP编译。您必须在 web.xml 中更改JSP servlet的默认配置。我将以下行添加到应用程序的 web.xml 注意两个参数 compilerSourceVM compilerTargetVM

I had the same problem with Apache Tomcat and it boiled down to that Tomcat (Apache Jasper library) is using Java 1.6 for JSP compilation by default. You'll have to change the default configuration of the JSP servlet in web.xml. I added the following lines to the application's web.xml, note the two parameters compilerSourceVM and compilerTargetVM:

<!-- Jasper JSP configuration -->
<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>
    <init-param>
        <param-name>compilerSourceVM</param-name>
        <param-value>1.7</param-value>
    </init-param>
    <init-param>
        <param-name>compilerTargetVM</param-name>
        <param-value>1.7</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
</servlet>

<!-- The mappings for the JSP servlet -->
<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.jsp</url-pattern>
    <url-pattern>*.jspx</url-pattern>
</servlet-mapping>

这篇关于Netbeans不会将JSP视为源级别7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆