当前位置: 技术问答>java相关
如何设置该class的import路径?在线等.......
来源: 互联网 发布时间:2015-07-24
本文导语: 我在写一个类时,如下: import javax.servlet.http.*; import org.apache.struts.action.*; public final class BookAction extends Action { public ActionForward perform(ActionMapping mapping, Action...
我在写一个类时,如下:
import javax.servlet.http.*;
import org.apache.struts.action.*;
public final class BookAction extends Action
{
public ActionForward perform(ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
System.out.println("Start perform(" + form + ") . . ." );
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");
}
}
当编译时提示:
BookAction.java:1: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
很明显,它找不到该package.
而我的路径为:
classpath=D:jdklibtools.jar;.;d:jdklibdt.jar;d:tomcatwebappsstruts.jar;d:tomcatcommonlibservlet.jar
Path=%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;d:MSSQL7BINN;C:Program FilesSymantecpcAnywhere;d:jdkbin
请问,我还需要设置什么地方?或是那里错了,请指点,谢谢!!!
import javax.servlet.http.*;
import org.apache.struts.action.*;
public final class BookAction extends Action
{
public ActionForward perform(ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
System.out.println("Start perform(" + form + ") . . ." );
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");
}
}
当编译时提示:
BookAction.java:1: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
很明显,它找不到该package.
而我的路径为:
classpath=D:jdklibtools.jar;.;d:jdklibdt.jar;d:tomcatwebappsstruts.jar;d:tomcatcommonlibservlet.jar
Path=%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;d:MSSQL7BINN;C:Program FilesSymantecpcAnywhere;d:jdkbin
请问,我还需要设置什么地方?或是那里错了,请指点,谢谢!!!
|
classpath=.;D:jdklib
试试
然后
试试
然后
|
你看一下servlet.jar包你有你想要的类不。
不然你就去下一个新版本的。
不然你就去下一个新版本的。