求助大神!为什么会报这个错误The requested resource is not available.

qq_37182376 2017-08-24 02:27:23


下面是userregister.jsp文件
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8" import="Servlet.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>用户注册</title>
<script type="text/javascript">
function check(){

if (userRegister.userName.value==""){
alert("用户名不能为空!");
userRegister.userName.focus();
return;
}
if (userRegister.password1.value.length<4){
alert("密码至少为4位!");
userRegister.password1.focus();
return;
}
if (userRegister.password2.value!=userRegister.password1.value){
alert("两次密码不一致!");
userRegister.password2.focus();
return;
}
if (userRegister.phoneNumber.value==""){
alert("手机号码不能为空!");
userRegister.phoneNumber.focus();
return;
}
if (userRegister.userEmail.value==""){
alert("userEmail不能为空!");
userRegister.userEmail.focus();
return;
}
alert("欢迎"+userRegister.userName.value+"!");
}
</script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>

<body>
<div id="Layer1" style="position:absolute; width:100%; height:100%; z-index:-1">
<img src="img/logo.png" height="100%" width="100%"/>
</div>
<form name="userRegister" action="Servlet/ServletUserRegister" method="post">
<table width=90% border=0 align=center>
<tr height=210px></tr>

<tr>
<td>
<table class="yuanjiao" align=center>
<tr>
<td height=100px colspan=2>
<p style="font-family: 宋体 ;font-size:40px;color:red;text-align:center;"><strong><b>用户注册</b></strong></p>
</td>
</tr>
<tr align=center>
<td>
<a style="font-family:宋体;font-size:20px;text-align:left;">用户名:</a>
</td>
<td>
<a><input type="text" name="userName" value="" style="width:200px;font-family:宋体;font-size:20px;text-align:left;"/></a>
</td>
</tr>
<tr align=center>
<td>
<a style="font-family:宋体;font-size:20px;text-align:left;">密码 :</a>
</td>
<td>
<input type="password"name="password1"value=""style="width:200px;font-family:宋体;font=size:20px;text-align:left;"/>
</td>
</tr>
<tr align=center>
<td>
<a style="font-family:宋体;font-size:20px;text-align:left;">确认密码:</a>
</td>
<td>
<input type="password"name="password2"value=""style="width:200px;font-family:宋体;font=size:20px;text-align:left;"/>
</td>
</tr>
<tr align=center>
<td>
<a style="font-family:宋体;font-size:20px;text-align:left;">手机号码:</a>
</td>
<td>
<input type="text"name="phoneNumber"value=""style="width:200px;font-family:宋体;font=size:20px;text-align:left;"/>
</td>
</tr>
<tr align=center>
<td>
<a style="font-family:宋体;font-size:20px;text-align:left;">Email:</a>
</td>
<td>
<input type="text"name="userEmail"value=""style="width:200px;font-family:宋体;font=size:20px;text-align:left;"/>
</td>
</tr>
<tr align=center>
<td>
<br/><br/>
<input type="button" value="登录" style="width:100%;font-family:宋体;font-size:20px;text-align:center;" onclick="javascrtpt:window.location.href='userlogin.jsp'"/><br/><br/>
</td>
<td>
<br/><br/>
<input type="submit" value="注册" style="width:100%;font-family:宋体;font-size:20px;text-align:center;" onclick="check()"/><br/><br/>
</td>
<td>
<br/><br/>
<input type="button" value="返回" style="width:100%;font-family:宋体;font-size:20px;text-align:center;" onclick="javascrtpt:window.location.href='index.html'"/><br/><br/>
</td>
</tr>
</table>
</td>
</tr>


</table>
</form>
</body>
</html>


下面是ServletUserRegister.java
package Servlet;

import java.io.IOException;

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

import Userbean.*;

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

request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
//设置编码格式为UTF-8
String userName = request.getParameter("userName");
String userPassword = request.getParameter("password1");
String phoneNumber = request.getParameter("phoneNumber");
String userEmail = request.getParameter("userEmail");
//前台得到用户输入数据
UserVo user = new UserVo();
//实例化一个VO对象
user.setUserName(userName);
user.setPassword(userPassword);
user.setPhoneNumber(phoneNumber);
user.setUserEmail(userEmail);
//将前台得到的数据存入VO
UserDao userDao = new UserDao();
//实例化一个数据库对象
userDao.insertUser(user);
//调用增加用户方法
System.out.println("已添加");
request.getRequestDispatcher("/index.html").forward(request, response);
//转跳到登陆页面
}
}


为什么之后运行就会出现了这个报错


是不是路径打错了
求!大神求助
...全文
584 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_37182376 2017-08-24
  • 打赏
  • 举报
回复
我这个项目没有用到web.xml所以就没写这个文件了
f0rd_ 2017-08-24
  • 打赏
  • 举报
回复
servlet没有继承 404肯定是路径问题
Freefish1994 2017-08-24
  • 打赏
  • 举报
回复
你连HttpServlet都不继承?
soton_dolphin 2017-08-24
  • 打赏
  • 举报
回复
你的 web.xml 文件呢?
qq_天使在唱歌 2017-08-24
  • 打赏
  • 举报
回复
路径:action="<%=request.getContextPath() %>/Servlet/ServletUserRegister"; servlet:地址 @WebServlet("/Servlet/ServletUserRegister" )
李德胜1995 2017-08-24
  • 打赏
  • 举报
回复

81,094

社区成员

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

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