当前位置: 技术问答>java相关
我已有servlet.jar,为什么它还说package http找不到呢?
来源: 互联网 发布时间:2015-08-25
本文导语: 程序如下: package com.wrox.sessions; import java.util.Vector; import java.servlet.http.HttpServletRequest; public class ShoppingCart extends Object { private Vector cart=null; String product=null; String submit=null; public ShoppingCart(){ cart=new Vector(); ...
程序如下:
package com.wrox.sessions;
import java.util.Vector;
import java.servlet.http.HttpServletRequest;
public class ShoppingCart extends Object {
private Vector cart=null;
String product=null;
String submit=null;
public ShoppingCart(){
cart=new Vector();
}
public void setProduct(String product){
this.product=product;
}
public void setSubmit(String submit){
this.submit=submit;
}
public Vector getProducts(){
return cart;
}
public void addProduct(String product){
cart.add(product);
}
public void removeProduct(String priduct){
cart.remove(product);
}
public void processRequest(HttpServletRequest req){
if (submit!=null){
if (submit.equals("add")){
addProduct(product);
} else {
removeProduct(product);
}
reset();
}
}
public void reset(){
submit=null;
product=null;
}
}
编译时出现如下错误:
D:tomcatwebappscookieWEB-INFclassescomwroxsessions>javac ShoppingCart.ja
va
ShoppingCart.java:3: cannot resolve symbol
symbol : class HttpServletRequest
location: package http
import java.servlet.http.HttpServletRequest;
^
ShoppingCart.java:30: cannot resolve symbol
symbol : class HttpServletRequest
location: class com.wrox.sessions.ShoppingCart
public void processRequest(HttpServletRequest req){
^
2 errors
我的类路径为:classpath=.;D:jdklib;d:jdkjrelibrt.jar;d:tomcatlibservlet.jar
我已有servlet.jar,为什么它还说package http找不到呢?
不明白。????
package com.wrox.sessions;
import java.util.Vector;
import java.servlet.http.HttpServletRequest;
public class ShoppingCart extends Object {
private Vector cart=null;
String product=null;
String submit=null;
public ShoppingCart(){
cart=new Vector();
}
public void setProduct(String product){
this.product=product;
}
public void setSubmit(String submit){
this.submit=submit;
}
public Vector getProducts(){
return cart;
}
public void addProduct(String product){
cart.add(product);
}
public void removeProduct(String priduct){
cart.remove(product);
}
public void processRequest(HttpServletRequest req){
if (submit!=null){
if (submit.equals("add")){
addProduct(product);
} else {
removeProduct(product);
}
reset();
}
}
public void reset(){
submit=null;
product=null;
}
}
编译时出现如下错误:
D:tomcatwebappscookieWEB-INFclassescomwroxsessions>javac ShoppingCart.ja
va
ShoppingCart.java:3: cannot resolve symbol
symbol : class HttpServletRequest
location: package http
import java.servlet.http.HttpServletRequest;
^
ShoppingCart.java:30: cannot resolve symbol
symbol : class HttpServletRequest
location: class com.wrox.sessions.ShoppingCart
public void processRequest(HttpServletRequest req){
^
2 errors
我的类路径为:classpath=.;D:jdklib;d:jdkjrelibrt.jar;d:tomcatlibservlet.jar
我已有servlet.jar,为什么它还说package http找不到呢?
不明白。????
|
弄错路径了
import java.servlet.http.HttpServletRequest;
应该改为:
import javax.servlet.http.HttpServletRequest;
import java.servlet.http.HttpServletRequest;
应该改为:
import javax.servlet.http.HttpServletRequest;
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。