关于Eclipse中不能import javax.servlet.http.*;的问题?急!

xx20031110 2007-05-22 01:17:46
很奇怪,我的Eclipse中怎么不能import 进和Servlet 有关的类呀?
在import 语句前面有红叉,提示不能导入javax.servlet,但是一般的java.开头的包又可以导入,如java.io.IOException,请指教!
谢谢,
我的Eclipse是配置了j2re1.4.2_07的,应该没有问题.
代码如下:
package family.yin.senqi;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Date;
import java.util.Calendar;
import family.yin.senqi.dao.MyDAO;
import family.yin.senqi.model.ModelFour;
import java.sql.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

public class BalanceServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
HttpSession session = req.getSession();
Calendar c = Calendar.getInstance();
int nYear = c.get(1);
int nMonth = c.MONTH+1;
String nYear_str = req.getParameter("nYear");
String nMonth_str = req.getParameter("nMonth");
if(nMonth_str!=null && nYear_str!=null){
nMonth = new Integer(nMonth_str).intValue();
}
MyDAO dao = new MyDAO();
try {
ModelFour[] mf = dao.getBalance(nYear, nMonth);
session.setAttribute("mf",mf);
float mTotal = dao.getMonthTotalMoney(nMonth);
session.setAttribute("mTotal",new Float(mTotal));
}
catch (SQLException ex) {
ex.printStackTrace();
}
resp.sendRedirect("balance.jsp?nYear="+nYear+"&nMonth="+nMonth);
}

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
this.doPost(req,resp);
}


}
...全文
901 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tomkan 2007-05-23
  • 打赏
  • 举报
回复
你的项目定义的是J2me MIDLET 类型默认情况下是不会包含J2EE当中要用的类库的,所以要像楼上那位添加一下extenal jar 才行
likgui 2007-05-23
  • 打赏
  • 举报
回复
关注
huoyin 2007-05-22
  • 打赏
  • 举报
回复
在你的工程中加入j2ee.jar库文件(可以从应用服务器的目录中去找)就可以了
imA 2007-05-22
  • 打赏
  • 举报
回复
找不到servlet的jar文件了。

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧