【ERROR】‘<>‘ operator is not allowed for source level below 1.7

简介: 【ERROR】‘<>‘ operator is not allowed for source level below 1.7

使用jsp时,服务器一直返回500,并报错:‘<>’ operator is not allowed for source level below 1.7

出错的部分代码如下:


<%--导包--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.zcongfly.pojo.Brand" %>
<%@ page import="java.util.ArrayList" %>
<%
    
    ArrayList<Brand> brands = new ArrayList<>();
    brands.add(new Brand(1,"三只松鼠","三只松鼠",100,"三只松鼠,好吃不上火",1));
    brands.add(new Brand(2,"优衣库","优衣库",200,"优衣库,服适人生",0));
    brands.add(new Brand(3,"小米","小米科技有限公司",1000,"为发烧而生",1));
%>


解决方法:


将代码

ArrayList<Brand> brands = new ArrayList<>();

修改成

ArrayList<Brand> brands = new ArrayList<Brand>();


原因是在1.7以下版本,不支持<>的修饰符,因此这行代码两边的泛型都要写全。


到此错误解决。

目录
相关文章
|
算法 C# C++
HALCON error #1201: Wrong type of control parameter: 1 in operator threshold
HALCON error #1201: Wrong type of control parameter: 1 in operator threshold
|
6月前
|
存储
tracker_query_storage fail, error no: 28, error info: No space left on device
tracker_query_storage fail, error no: 28, error info: No space left on device
159 0
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
122 0
|
6月前
|
Perl
报错:error Parsing error: x-invalid-end-tag
报错:error Parsing error: x-invalid-end-tag
136 0
|
6月前
|
前端开发
Fatal error_ ENOSPC_ System limit for number of file watchers reached, watch '...path...'
Fatal error_ ENOSPC_ System limit for number of file watchers reached, watch '...path...'
55 0
error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
140 0
Optional int parameter ‘id‘ is present but cannot be translated into a null value due to being ……
Optional int parameter ‘id‘ is present but cannot be translated into a null value due to being ……
305 0
|
C语言
error: implicit declaration of function ‘VerifyFixClassname‘ is invalid in C99 [-Werror,-Wimplicit-f
error: implicit declaration of function ‘VerifyFixClassname‘ is invalid in C99 [-Werror,-Wimplicit-f
148 0
error: invalid argument ‘-std=gnu++98‘ not allowed with ‘C‘
error: invalid argument ‘-std=gnu++98‘ not allowed with ‘C‘
116 0