无法为JSP编译类:x无法解析为类型

时间:2016-04-20 19:46:27

标签: java jsp import

在过去的几天里,我浏览了许多类似的帖子并尝试了许多解决方案。没有人工作过。

我通常不会使用Java,但我团队中的主要Java人员已离开办公室几周,我想在此期间完成一个项目。

问题在于:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page session="false"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.io.File" %>
<%@page import="java.io.FileInputStream" %>
<%@page import="java.util.Properties" %>

<%@page import="a.custom.package.path.FilterVO" %>
<%@page import="a.custom.package.path.CodeTypeSearchResultsDTO" %>
<%@page import="a.custom.package.path.CodeDTO" %>

<html>
    <head>
        <!-- Code in question begin ======================================== -->
        <%
            // Create filter.
            FilterVO filter = new FilterVO();
            filter.setActive(true);


            // Execute search.
            CodeSearchResultsDTO results = getMyClient().getSystemFacade().getSomePreferences(filter, new Range(1, 10), "");

            for (CodeDTO code : results.getCodes())
            {
                System.out.println("Some Preference: " + code);
            }
        %>
        <!-- Code in question end ========================================== -->



        <!-- Some CSS imports and JS imports are here. -->

        <%
            <!-- Some currently working java code here that references the first 3 java imports at the top of the page. -->
        %>

    </head>
   <body>

    </body>
</html>

以下是错误:

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

An error occurred at line: 28 in the jsp file: /index.jsp
CodeSearchResultsDTO cannot be resolved to a type
25: 
26: 
27:             // Execute search.
28:             CodeSearchResultsDTO results = getMyClient().getSystemFacade().getSomePreferences(filter, new Range(1, 10), "");
29: 
30:             for (CodeDTO code : results.getCodes())
31:             {


An error occurred at line: 28 in the jsp file: /index.jsp
The method getMyClient() is undefined for the type index_jsp
25: 
26: 
27:             // Execute search.
28:             CodeSearchResultsDTO results = getMyClient().getSystemFacade().getSomePreferences(filter, new Range(1, 10), "");
29: 
30:             for (CodeDTO code : results.getCodes())
31:             {


An error occurred at line: 28 in the jsp file: /index.jsp
Range cannot be resolved to a type
25: 
26: 
27:             // Execute search.
28:             CodeSearchResultsDTO results = getMyClient().getSystemFacade().getSomePreferences(filter, new Range(1, 10), "");
29: 
30:             for (CodeDTO code : results.getCodes())
31:             {


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:460)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:723)

这些类位于WEB-INF / lib jar中,因为它们不会丢失。路径是正确的。外壳是正确的。我试过清理&#39;我的容器删除CATALINA_BASE / work / Catalina / localhost文件夹。我试图清理所有浏览器现金,因为这是出于某种原因(似乎是一个长镜头)。

我倾向于它是一个容器java依赖刷新问题,但同样,Java和容器并不是我的MO。

我现在意识到我还没有导入Range类,我将添加它,但是这不会阻止找不到这些导入的主要问题。

任何调试建议将不胜感激!干杯!

1 个答案:

答案 0 :(得分:1)

我认为这里出了点问题。

这是您导入的内容

<%@page import="a.custom.package.path.CodeTypeSearchResultsDTO" %>

这就是你所说的

CodeSearchResultsDTO

可能是Typ(e)o ??