0

我收到类似的错误

org.apache.jasper.JasperException: Unable to compile class for JSP: 
An error occurred at line: 6 in the generated java file
Only a type can be imported. com.sixpanview.getcoordinate resolves to a package
An error occurred at line: 7 in the generated java file
Only a type can be imported. com.sixpanview.fileReader resolves to a package
An error occurred at line: 8 in the generated java file
Only a type can be imported. com.sixpanview.cookieInfo resolves to a package

并在使用getcoordinate,fileReadercookieInfo.jsp 程序的行中出现错误,并且堆栈跟踪是

at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
        at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
        at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:679)

为什么我会得到它?

4

1 回答 1

1

您不能导入package. 您需要classes在该包中导入。

在您的导入语句中,将您的导入替换为:-

com.sixpanview.getcoordinate.*;
com.sixpanview.fileReader.*;
com.sixpanview.cookieInfo.*;

我假设这些包下没有其他子包。

.*将导入该包下的所有类。理想情况下,您不应该这样做。import如果您知道它们是什么,而是这些包中的特定类。

喜欢: -

import java.util.List; 

优于:-

import java.util.*;

PS : -请不要bold case在您的内容中使用,除非突出显示真的很重要。它很难阅读。并在将来发布您的代码片段,同时发布异常。

于 2012-11-17T11:30:13.707 回答