我安装了 JDK 7 并使用了 tomcat 7。
我现在在字符串变量上使用 switch
时遇到此错误,
Cannot switch on a value of type String for source level below 1.7
我还为 JDK 7 设置了类路径,但我没有安装 JDK 6。如何解决?
最佳答案
默认的 Tomcat JSP 编译器将编译为 Java 1.6。 查看Tomcat documentation了解如何指定 JSP 页面使用哪个编译器。
查看这些参数:
compiler - Which compiler Ant should use to compile JSP pages. The valid values for this are the same as for the compiler attribute of Ant's javac task. If the value is not set, then the default Eclipse JDT Java compiler will be used instead of using Ant. There is no default value. If this attribute is set then setenv.[sh|bat] should be used to add ant.jar, ant-launcher.jar and tools.jar to the CLASSPATH environment variable.
compilerSourceVM - What JDK version are the source files compatible with? (Default value: 1.6)
compilerTargetVM - What JDK version are the generated files compatible with? (Default value: 1.6)
关于java - 无法在 JDK 7 中打开 String 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17545720/