“生成的servlet错误:<class>无法解析为页面</class>中的类型”

时间:2012-08-01 12:43:16

标签: java jsp exception jna

我正在尝试实施JNA。我已将以下代码用于测试目的。现在我得到一个例外。如果我使用的方法不正确或者我的测试代码有任何问题,请纠正我。

我的参考教程是thisthis

我的类FileModifierLinux:

import com.sun.jna.Library;
import com.sun.jna.Native;

public class FileModifierLinux {
     CLibrary libc = (CLibrary) Native.loadLibrary("c", CLibrary.class);
    public void Update(String pth) {
        libc.chmod(pth, 0755);
    }
}
interface CLibrary extends Library {
    public int chmod(String path, int mode);
}

我的页面:

<%

try
{
    FileModifierLinux flx=new FileModifierLinux();
    String pathX = getServletContext().getRealPath("/testpage.jsp");
    flx.Update(pathX);
    out.println("No Exception");
}
catch(Exception exp)
{
    out.println("exp :"+exp);
}
%>

例外:

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

An error occurred at line: 15 in the jsp file: /index.jsp
Generated servlet error:
FileModifierLinux cannot be resolved to a type

An error occurred at line: 15 in the jsp file: /index.jsp
Generated servlet error:
FileModifierLinux cannot be resolved to a type

    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

1 个答案:

答案 0 :(得分:0)

import中的index.jsp班级了吗?像:

<%@page import="com.somepackage.FileModifierLinux "%>