ff19970721
2017-05-31 12:19
采纳率: 66.7%
浏览 1.3k
已采纳

HTTP Status 404 description 求帮忙

java课程作业,已经配置成功tomcat,并可以实现登录界面,但是在修改的过程中由于我加了注册功能,出现了错误,如图
图片说明
其中register.jsp的代码为

<%@ page language="java" import="java.util." pageEncoding="UTF-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">







请输入帐号:


请输入密码:


请确认密码:





${msg }












registeredservlet.java的代码为:
package casecom.Servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import casecom.bean.user;
import util.JdbcConnecter;

public class RegisterServlet {
private static final long serialVersionUID = 1L;

public void doPost(HttpServletRequest request, HttpServletResponse response)  
        throws ServletException, IOException {  

    user u = new user();                       //声明一个user类对象,用来储存用户输入的信息
    request.setCharacterEncoding("UTF-8");     //定义传入数据的格式,防止中文乱码
    u.setUsername(request.getParameter("username"));    //获得用户输入的用户名栏的内容,并赋值于user类的username。
    u.setPassword(request.getParameter("password"));    //获得用户输入的密码栏的内容,并赋值于user类的password。
    u.setParameter(request.getParameter("rpsw"));//得到表单输入的内容  
    if(u.getUsername().equals("")){  
        request.setAttribute("msg", "帐号不能为空");  
        request.getRequestDispatcher("/regist.jsp").forward(request, response);  
        return;  
    }  
    if(u.getPassword().equals("")){  
        request.setAttribute("msg", "密码不能为空");  
        request.getRequestDispatcher("/regist.jsp").forward(request, response);  
        return;  
    }  
    if(!u.getPassword().equals(u.getParameter())){  
        request.setAttribute("msg", "两次输入的密码不同");  
        request.getRequestDispatcher("/regist.jsp").forward(request, response);  
        return;  
    }  
    JdbcConnecter  j = new JdbcConnecter ();  
    j.addUser(u.getUsername(),u.getPassword());//调用addUser()方法  
    request.setAttribute("msg", "恭喜:"+u.getUsername()+",注册成功");  
    request.getRequestDispatcher("/index.jsp").forward(request, response);  

}  

}
修改后的web.xml是
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


This is the description of my J2EE component
This is the display name of my J2EE component
LoginServlet
casecom.Servlet.LoginServlet


This is the description of my J2EE component
This is the display name of my J2EE component
Servlet
casecom.Servlet.Servlet


This is the description of my J2EE component
This is the display name of my J2EE component
AbServlet
casecom.Servlet.AbServlet


This is the description of my J2EE component
This is the display name of my J2EE component
RegisterServlet
casecom.Servlet.RegisterServlet


LoginServlet
/servlet/LoginServlet


Servlet
/Servlet


AbServlet
/servlet/AbServlet


RegisterServlet
/servlet/RegisterServlet



index.jsp


之前登录实现也是好的,一注册就出错了,求大神解决~

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

4条回答 默认 最新

相关推荐 更多相似问题