当前位置: 技术问答>java相关
大家帮忙:JavaBean问题!
来源: 互联网 发布时间:2015-07-18
本文导语: 底下是编译时出现的错误信息: 是不是我的javax.servlet.http 不存在,我是初学者,如果是的话, 我该如何解决。谢谢! FileUploadBean.java:4: package javax.servlet.http does not exist import javax.servlet.http.HttpServletRequest; ...
底下是编译时出现的错误信息:
是不是我的javax.servlet.http 不存在,我是初学者,如果是的话,
我该如何解决。谢谢!
FileUploadBean.java:4: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletRequest;
^
FileUploadBean.java:5: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
^
FileUploadBean.java:6: package javax.servlet does not exist
import javax.servlet.ServletInputStream;
^
FileUploadBean.java:10: cannot resolve symbol
symbol : class HttpServletRequest
location: class db.FileUploadBean
public void doUpload(HttpServletRequest request) throws
^
FileUploadBean.java:14: cannot resolve symbol
symbol : class ServletInputStream
location: class db.FileUploadBean
ServletInputStream in = request.getInputStream();
^
5 errors
底下是源代码!
package db;
import java.io.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletInputStream;
public class FileUploadBean {
public void doUpload(HttpServletRequest request) throws
IOException {
PrintWriter pw = new PrintWriter(
new BufferedWriter(new FileWriter("Demo.out")));
ServletInputStream in = request.getInputStream();
int i = in.read();
while (i != -1) {
pw.print((char) i);
i = in.read();
}
pw.close();
}
}
是不是我的javax.servlet.http 不存在,我是初学者,如果是的话,
我该如何解决。谢谢!
FileUploadBean.java:4: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletRequest;
^
FileUploadBean.java:5: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
^
FileUploadBean.java:6: package javax.servlet does not exist
import javax.servlet.ServletInputStream;
^
FileUploadBean.java:10: cannot resolve symbol
symbol : class HttpServletRequest
location: class db.FileUploadBean
public void doUpload(HttpServletRequest request) throws
^
FileUploadBean.java:14: cannot resolve symbol
symbol : class ServletInputStream
location: class db.FileUploadBean
ServletInputStream in = request.getInputStream();
^
5 errors
底下是源代码!
package db;
import java.io.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletInputStream;
public class FileUploadBean {
public void doUpload(HttpServletRequest request) throws
IOException {
PrintWriter pw = new PrintWriter(
new BufferedWriter(new FileWriter("Demo.out")));
ServletInputStream in = request.getInputStream();
int i = in.read();
while (i != -1) {
pw.print((char) i);
i = in.read();
}
pw.close();
}
}
|
你应该把servlet.jar加到你的classpath中。
servlet在/lib/servlet.jar
servlet在/lib/servlet.jar
|
它是说javax.servlet.http 这个包不在classpath中.
如果你用jbuilder的话,先在project中导入tomcat的servlet包.
如果你用jbuilder的话,先在project中导入tomcat的servlet包.
|
楼上说得对
看看javax.servlet.http 包保函进来了没有!
看看javax.servlet.http 包保函进来了没有!
|
/tomcat/common/lib