【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以下版本,不支持<>的修饰符,因此这行代码两边的泛型都要写全。


到此错误解决。

目录
相关文章
|
11月前
|
算法 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
|
3月前
|
存储 缓存 自然语言处理
“error“: { “root_cause“: [{ “type“: “circuit_breaking_exception“, “reason“: “[parent] D【已解决】
“error“: { “root_cause“: [{ “type“: “circuit_breaking_exception“, “reason“: “[parent] D【已解决】
36 1
|
4月前
|
索引
Elasticsearch exception [type=illegal_argument_exception, reason=index [.1] is the write index for data stream [slowlog] and cannot be deleted]
在 Elasticsearch 中,你尝试删除的索引是一个数据流(data stream)的一部分,而且是数据流的写入索引(write index),因此无法直接删除它。为了解决这个问题,你可以按照以下步骤进行操作:
186 0
|
4月前
|
存储
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
123 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 : ‘}‘
106 0
error: invalid argument ‘-std=gnu++98‘ not allowed with ‘C‘
error: invalid argument ‘-std=gnu++98‘ not allowed with ‘C‘
109 0
|
Java Android开发
is not allowed for source level below 1.7 的解决办法
is not allowed for source level below 1.7 的解决办法
174 0
|
网络协议 关系型数据库 Linux
onfigure: error: no acceptable C compiler found in $PATH See `config.log' for more details 问题解决
onfigure: error: no acceptable C compiler found in $PATH See `config.log' for more details 问题解决
178 0
|
Linux
WARNING: Re-reading the partition table failed with error 22: Invalid argument
在划分磁盘分区时,遇到错误“WARNING: Re-reading the partition table failed with error 22: Invalid argument” 如下所示: [root@DB-Server u02]# fdisk -l   Disk /dev/sda: 500.
2528 0
SAP WM Storage Type Capacity Check Method 5 (Usage check based on SUT)
SAP WM Storage Type Capacity Check Method 5 (Usage check based on SUT)
SAP WM Storage Type Capacity Check Method 5 (Usage check based on SUT)