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

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

问题描述

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

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

输入异常报告

消息内部服务器错误

描述服务器遇到内部错误,无法完成此请求.

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.jspPWC6199:生成的 servlet 错误:-source 1.5 不支持菱形运算符(使用 -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 开源版 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 设置为 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 无关,而与使用的应用服务器有关.怀疑您使用的是 GlassfishTomcat,因为它们与 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中添加了以下几行,注意两个参数compilerSourceVMcompilerTargetVM:>

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 视为 Source Level 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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