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


到此错误解决。

目录
相关文章
|
SpringCloudAlibaba 负载均衡 Dubbo
【SpringCloud Alibaba系列】Dubbo高级特性篇
本章我们介绍Dubbo的常用高级特性,包括序列化、地址缓存、超时与重试机制、多版本、负载均衡。集群容错、服务降级等。
2291 7
【SpringCloud Alibaba系列】Dubbo高级特性篇
|
前端开发 应用服务中间件 nginx
docker运行nginx镜像
这篇文章详细说明了如何在Docker中部署并运行Nginx服务,包括拉取镜像、配置文件的挂载以及容器的启动配置。
2626 0
docker运行nginx镜像
|
JSON 监控 前端开发
OIDC协议会话管理相关技术介绍
## 介绍 > OpenID Connect 1.0 is a simple identity layer on top of the OAuth 2.0 [[RFC6749]](https://openid.net/specs/openid-connect-session-1_0.html#RFC6749) protocol. It enables Clients to verify the i
2254 0
OIDC协议会话管理相关技术介绍
|
Java 数据库 Nacos
Nacos Committer 张龙:Nacos Sync 的设计原理和规划
图:Nacos Meetup @杭州 与你同行,抬头便是星空。 本文整理自Nacos Committer 张龙的现场分享,阿里巴巴中间件受权发布。 随着 Nacos 1.0.0 稳定版的发布,越来越多的企业开始在测试/预演/生产环境中逐步部署 Nacos。
5081 109
|
Java 程序员
java截取字符串的几种方法
java截取字符串的几种方法
1113 0
|
芯片 Windows
一文带你认识 CP210x 并安装驱动
一文带你认识 CP210x 并安装驱动
6024 0
Idea的server.port端口不生效yml配置文件不生效
Idea的server.port端口不生效yml配置文件不生效
1764 2
|
负载均衡 算法 Nacos
SpringCloud之LoadBalancer自定义负载均衡算法,基于nacos权重
ReactorLoadBalancer接口,实现自定义负载算法需要实现该接口,并实现choose逻辑,选取对应的节点。
2303 0
|
SQL XML Java
关于mybatis-plus写自定义方法(自定义sql)
关于mybatis-plus写自定义方法(自定义sql)
1268 1