[英]String is not working with Switch case in JSP with java 7 and Tomcat 7
I am using jdk1.7.0 and tomcat 7.0.27 我正在使用jdk1.7.0和tomcat 7.0.27
A program of switch case with String parameter is working fine in JAVA but same program is not working with JSP. 在Java中,带有String参数的switch case程序可以正常工作,但JSP不能使用同一程序。
An error Occurred : "Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted"
发生错误:“对于低于1.7的源级别,无法打开String类型的值。仅允许使用可转换的int值或枚举常量”
Any suggestions for resolving this issue. 解决此问题的任何建议。
Apparently, you have to specify what version of Java should be used when compiling JSPs. 显然,您必须指定在编译JSP时应使用哪个Java版本。
Add this compilerTargetVM
init-param in tomcat/conf/web.xml (here I'm targeting Java 8): 在tomcat / conf / web.xml中添加此
compilerTargetVM
init-param(这里我针对Java 8):
<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>compilerTargetVM</param-name>
<param-value>1.8</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.