gpt4 book ai didi

java - 我正在尝试在 tomcat 6.0 中运行一个 jsp 项目。但我收到以下错误

转载 作者:行者123 更新时间:2023-11-28 23:29:10 25 4
gpt4 key购买 nike

异常(exception):

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

在 jsp 文件中的第 152 行发生错误:/user.jsp无法解析类型 java.lang.CharSequence。它是从所需的 .class 文件中间接引用的

 149:       int length=5;
150: for (int i = 0; i <= length; i++ ) {
151: int pos = rand.nextInt(charset1.length());
152: sb.append(charset1.charAt(pos));
153: }

堆栈跟踪:

    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.

最佳答案

Java 8 supports default methods in interfaces. And in JDK 8 a lot of old interfaces now have new default methods. For example, now in CharSequence we have chars and codePoints methods. If source level of your project is lower than 1.8, then compiler doesn't allow you to use default methods in interfaces. So it cannot compile classes that directly on indirectly depend on this interfaces. If I get your problem right, then you have two solutions. First solution is to rollback to JDK 7, then you will use old CharSequence interface without default methods. Second solution is to set source level of your project to 1.8, then your compiler will not complain about default methods in interfaces.

引用:The type java.lang.CharSequence cannot be resolved in package declaration

关于java - 我正在尝试在 tomcat 6.0 中运行一个 jsp 项目。但我收到以下错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32905503/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com