把你的小程序贴出来,肯定是你程序问题你的包怎么设成了package org.apache.struts.action

解决方案 »

  1.   

    import javax.servelet.http.*;
    import org.apache.struts.action.*;
    import books.Book;public final class BookAction extends Action
    {public ActionForward perform(ActionMapping mapping,
    ActionForm form, HttpServletRequest req,
    HttpServletResponse res)
    {    String title = req.getParameter("title");
        Book book = new Book();
        book.setTitle( title );
        System.out.println("After creation of book: " + book.getTitle() );
        req.setAttribute("BOOK", book);
        return mapping.findForward("bookCreated");
    }
    }
    我没设这个包阿!
      

  2.   

    我是编译时出错的,import javax.servelet.http.*;
    import org.apache.struts.action.*;
    import books.Book;public final class BookAction extends Action
    {public ActionForward perform(ActionMapping mapping,
    ActionForm form, HttpServletRequest req,
    HttpServletResponse res)
    {    String title = req.getParameter("title");
        Book book = new Book();
        book.setTitle( title );
        System.out.println("After creation of book: " + book.getTitle() );
        req.setAttribute("BOOK", book);
        return mapping.findForward("bookCreated");
    }
    }
    编译后。提示错误:
      package org.apache.struts.action does not exist
    也就是说编译器未找到struts的包,但是我已经将struts.jar拷到当前的应用的lib路径下
    是不是还要做什么设置,
      

  3.   

    把你的struts.jar
    放到这个地方
    tomcat/share/lib
    试试看
      

  4.   

    是用的JB吗?(jbuidler)
    如果用JB的话可在工程文件处点右键
    选择properties 
    选择paths一栏中的Required libraries
    在其中加入你的struts.jar就可以了
      

  5.   

    编译出错,说明classpath设置的不对
      

  6.   

    应该是classpath设置的不对,导致找不到class