[英]I am trying to run a jsp project in tomcat 6.0. But I am getting the following error
exception: 例外:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 152 in the jsp file: /user.jsp The type java.lang.CharSequence cannot be resolved. jsp文件:/user.jsp中的第152行发生错误:无法解析类型java.lang.CharSequence。 It is indirectly referenced from required .class files
从所需的.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: }
Stacktrace: 堆栈跟踪:
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.
Java 8支持接口中的默认方法。 And in JDK 8 a lot of old interfaces now have new default methods.
在JDK 8中,许多旧接口现在具有新的默认方法。 For example, now in CharSequence we have chars and codePoints methods.
例如,现在在CharSequence中,我们有chars和codePoints方法。 If source level of your project is lower than 1.8, then compiler doesn't allow you to use default methods in interfaces.
如果项目的源级别低于1.8,则编译器不允许您在接口中使用默认方法。 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.
第一个解决方案是回滚到JDK 7,然后您将使用旧的CharSequence接口,而没有默认方法。 Second solution is to set source level of your project to 1.8, then your compiler will not complain about default methods in interfaces.
第二种解决方案是将项目的源代码级别设置为1.8,这样编译器将不会抱怨接口中的默认方法。
Ref : The type java.lang.CharSequence cannot be resolved in package declaration 参考: 在包声明中无法解析类型java.lang.CharSequence
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.