首页上一页 1 下一页尾页 1 条记录 1/1页
创建的servlet总是调用不上
发表在JavaWeb图书答疑
2012-11-14
是否精华
是
否
版块置顶:
是
否
在运行项目时总是提示:HTTP Status 404 - /yuanlai/CustomerServlet
--------------------------------------------------------------------------------
type Status report
message /yuanlai/CustomerServlet
description The requested resource (/yuanlai/CustomerServlet) is not available.
代码我和源码一样了就是运行不上,不知道是怎么回事,希望明日科技给我解释一下 网上我也找了 可是还是没找到,总是调用不上
代码:
public class CustomerServlet extends HttpServlet {
private static final long serialVersionUID = -215653077628523281L;
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username=request.getParameter("username");
String password=request.getParameter("password");
String sex=request.getParameter("sex");
String age=request.getParameter("age");
String desc=request.getParameter("description");
if(username!=null&&password!=null)
{
Customer customer=new Customer();
customer.setUsername(username);
customer.setPassword(password);
if(sex!=null)
{
customer.setSex(sex.equals("1")?true:false);
}
customer.setAge(Integer.parseInt(age));
customer.setDescription(desc);
CustomerDao dao=new CustomerDao();
dao.saveCustomer(customer);
request.setAttribute("info", "恭喜,注册成功");
}
request.getRequestDispatcher("result.jsp").forward(request, response);
}
}代码应该没错吧,调用这个就出现上面的问题,烦。。。求解
--------------------------------------------------------------------------------
type Status report
message /yuanlai/CustomerServlet
description The requested resource (/yuanlai/CustomerServlet) is not available.
代码我和源码一样了就是运行不上,不知道是怎么回事,希望明日科技给我解释一下 网上我也找了 可是还是没找到,总是调用不上
代码:
public class CustomerServlet extends HttpServlet {
private static final long serialVersionUID = -215653077628523281L;
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username=request.getParameter("username");
String password=request.getParameter("password");
String sex=request.getParameter("sex");
String age=request.getParameter("age");
String desc=request.getParameter("description");
if(username!=null&&password!=null)
{
Customer customer=new Customer();
customer.setUsername(username);
customer.setPassword(password);
if(sex!=null)
{
customer.setSex(sex.equals("1")?true:false);
}
customer.setAge(Integer.parseInt(age));
customer.setDescription(desc);
CustomerDao dao=new CustomerDao();
dao.saveCustomer(customer);
request.setAttribute("info", "恭喜,注册成功");
}
request.getRequestDispatcher("result.jsp").forward(request, response);
}
}代码应该没错吧,调用这个就出现上面的问题,烦。。。求解