简体   繁体   English

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

[英]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.

相关问题 嗨,我正在尝试在 tomcat 10 中部署 spring mvc 项目,但出现以下错误。 我搜索了很多但没有找到解决方案 - Hi I am trying to deploy spring mvc project in tomcat 10 but I am getting following error . I search a lot but not find the solution 我正在尝试从jsp运行shell脚本,但出现Ljava.lang.string错误 - i am trying to run a shell script from jsp but i am getting Ljava.lang.string error 我一直在尝试在 intelliJ 中运行 selenium 基本测试,但出现以下错误 - I have been trying to run selenium basic test in intelliJ and I am getting the following error 尝试在jmeter 4.0上运行Http测试脚本记录时出现以下错误 - I am getting the following error while trying to run Http Test Script Record on jmeter 4.0 当我试图解密获得以下错误 - When I am trying to decrypt getting following error 我正在尝试使用 XML 运行第一个 Spring 程序,但出现以下错误。 我是新手,请指导我 - I am trying to run this first Spring program using XML and I am getting following error. I am novice in this, Please guide me 尝试运行项目时出现错误java.lang.reflect.InvocationTargetException - I am getting error java.lang.reflect.InvocationTargetException when trying to run the project 我正在尝试运行以下提到的代码,但出现错误 - I am trying to run the below mentioned code but getting an error 我在尝试运行 Appium 测试时遇到错误 - i am getting an error trying to run Appium test 在Hibernate中,我在运行时遇到以下错误 - In Hibernate,I am getting following error at runtime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM