类型不匹配:无法从 ArrayList<?> 转换为 tomcat 中的 ArrayList<String> 7

Type mismatch: cannot convert from ArrayList<?> to ArrayList<String> in tomcat 7

我正在将我的第一个 tomcat 7 Web 应用程序部署到我的生产服务器,但我遇到了麻烦...

Web 应用程序在我的开发机器上完美运行,在 Eclicpse Luna 中本地安装了 tomcat 7。 但是当我尝试在生产服务器上 运行 它时 (Ubuntu 12.04 + Tomcat 7 + openjdk-7-jre-headless),login.jsp 页面给了我很多编译错误数:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 10 in the jsp file: /header.jsp
Type mismatch: cannot convert from ArrayList<?> to ArrayList<String>
7: <head>
8:  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9:  <% 
10:     ArrayList<String> whiteList = new ArrayList<>(
11:             Arrays.asList("login.jsp"));
12: 
13:     String pg = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/")+1);


An error occurred at line: 10 in the jsp file: /header.jsp
Cannot instantiate the type ArrayList<?>
7: <head>
8:  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9:  <% 
10:     ArrayList<String> whiteList = new ArrayList<>(
11:             Arrays.asList("login.jsp"));
12: 
13:     String pg = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/")+1);


An error occurred at line: 10 in the jsp file: /header.jsp
Syntax error on token "<", ? expected after this token
7: <head>
8:  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9:  <% 
10:     ArrayList<String> whiteList = new ArrayList<>(
11:             Arrays.asList("login.jsp"));
12: 
13:     String pg = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/")+1);


Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

我想我的生产机器或配置文件中缺少某些东西...

更换

即可解决问题
ArrayList<String> whiteList = new ArrayList<>(Arrays.asList("login.jsp"));

ArrayList<String> whiteList = new ArrayList<String>(Arrays.asList("login.jsp"));

关于为什么它在本地运行而不在 'Live' 中运行,也许您使用的是不同版本的 jar(例如 servlet-api.jar)?