JSP 出现 “Cannot switch on a value of type String for source level below 1.7” 的解决方法
2018-03-19 15:20
986 查看
在 IDEA 中运行一个新项目,执行到某个 JSP 页面时,出现以下错误:
之前的JDK 版本虽然是 1.8,但编译的二进制码版本却是 1.6。
Tomcat 用的是 7.x,而 Tomcat 必须从 8.x 及之后的版本,才能使用 JDK 1.7 的新特性。
Settings → Java Complier :
Project Structure → Project :
2、升级 Tomcat 版本到 8.x 及以上
Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted
1 分析
因为 JDK 到 1.7 及以后的版本才支持在 switch 语句中使用 String 类型的值。之前的JDK 版本虽然是 1.8,但编译的二进制码版本却是 1.6。
Tomcat 用的是 7.x,而 Tomcat 必须从 8.x 及之后的版本,才能使用 JDK 1.7 的新特性。
2 解决
1、 修改 IDEA 的编译版本Settings → Java Complier :
Project Structure → Project :
2、升级 Tomcat 版本到 8.x 及以上
相关文章推荐
- android switch(String)错误:Cannot switch on a value of type String for source level below 1.7
- Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted
- Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted
- Eclipse下JSP文件出现string cannot be resolved to a type的解决方法
- Multi-catch parameters are not allowed for source level below 1.7 解决方法
- (7)JSP页面中出现“String cannot be resolved to a type”的解决方法
- Myeclipse/Eclipse下JSP文件出现string cannot be resolved to a type的解决方法
- jsp页面出现“String cannot be resolved to a type”异常解决方法
- Dynamics CRM2016 The value of field on record of type entity is outside the valid range问题的解决方法
- No converter found for return value of type解决方法
- idea javaweb项目 jsp页面报错:'<>'operator is not allowed for source level below 1.7
- 问题解决:javax.servlet.jsp.el.ELException: The "." operator was supplied with an index value of type "java.lang.String" to be applie
- Type of the default value for 'data' prop must be a function的解决方法
- spring mvc 出现“Failed to convert property value of type”解决方法
- Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching e
- jsp页面出现“String cannot be resolved to a type”错误解决办法
- ASP.NET MVC运行出现Uncaught TypeError: Cannot set property __MVC_FormValidation of null的解决方法
- Dynamics CRM2016 The value of field on record of type entity is outside the valid range问题的解决方法
- Spring MVC No converter found for return value of type 解决方法
- Dynamics CRM2016 The value of field on record of type entity is outside the valid range问题的解决方法