Jboss jsp问题<>操作员不允许源级别低于1.7

时间:2014-05-20 13:56:36

标签: java jsp jboss

我使用JDK 7在我的服务器上运行jboss eap 6.2.2。在我的Web应用程序中,我有一个使用jdk7钻石操作符的jsp

Map<String, String> menuItems = new LinkedHashMap<>();

我在访问此jsp时遇到错误:

org.apache.jasper.JasperException: JBWEB004062: Unable to compile class for JSP: 
JBWEB004060: An error occurred at line: 5 in the jsp file: /WEB-INF/pagecomponents/menu.jsp
'<>' operator is not allowed for source level below 1.7

是否存在jboss使用的默认源兼容性,如果有,是否可以更改它?

1 个答案:

答案 0 :(得分:2)

注意:我已经在EAP 6.1.0上对此进行了测试,但相信它在6.2.2上应该是相同的。

JSP编译由JBoss EAP 6下的Web子系统执行。

如果你看一下“jboss:domain:web:1.4”的模式,你可以看到编译器的默认值是1.5,https://github.com/wildfly/wildfly/blob/master/build/src/main/resources/docs/schema/jboss-as-web_1_4.xsd

<xs:complexType name="jsp-configurationType">
      ...
      <xs:attribute name="scratch-dir" />
      <xs:attribute name="source-vm" default="1.5" />
      <xs:attribute name="target-vm" default="1.5" />

您可以在standalone-full.xml中更改此设置。我的本地副本如下:

<subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="false">
    <configuration>
    <jsp-configuration source-vm="1.7" target-vm="1.7"/>
    ...

有一种观点认为,如果你应该尽可能地限制你的scriptlet代码,那么最好将你的代码移出JSP