你把这个类编译一下 如果你用的是tomcat的话 你把这个文件放在你的web应用程序下的WEB-INF下的classes下

解决方案 »

  1.   

    如果你的类有包结构的话只需要在jsp开头部分 把这个文件引用进来就可以了。
    <%@ page import="aa.bb.cc.TestNative"%>如果没有包结构 只是一个单独的class文件的话
    在jsp用就需要用到jsp标签了
    <jsp:userBean id="testnative" class="TestNative" scope="page">
    然后是
    int y=testnative.add(10,20);
    out.print(y);就可以了
      

  2.   

    有下面的错误啊,
    D:\Work\temptest\TestXML1\work\org\apache\jsp\counter_jsp.java文件是tomcat自己产生的.
    我用的平台是eclipse+tomcat.
    D:\Work\temptest\TestXML1\work\org\apache\jsp\counter_jsp.java:45: cannot resolve symbol
    symbol  : class TestNative 
    location: class org.apache.jsp.counter_jsp
          TestNative testnative = null;^
    An error occurred at line: 4 in the jsp file: /counter.jsp
    Generated servlet error:
    D:\Work\temptest\TestXML1\work\org\apache\jsp\counter_jsp.java:47: cannot resolve symbol
    symbol  : class TestNative 
    location: class org.apache.jsp.counter_jsp
            testnative = (TestNative) _jspx_page_context.getAttribute("testnative", PageContext.PAGE_SCOPE);
                          ^
    An error occurred at line: 4 in the jsp file: /counter.jsp
    Generated servlet error:
    D:\Work\temptest\TestXML1\work\org\apache\jsp\counter_jsp.java:49: cannot resolve symbol
    symbol  : class TestNative 
    location: class org.apache.jsp.counter_jsp
              testnative = new TestNative();