老师,我的在eclipse下一直报404错误
HTTP Status 404 – Not Found
Type Status Report
Message /index
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.37
代码:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
<%
response.sendRedirect("/index");
%>
</body>
</html>
package com.damu.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.damu.dao.UserDao;
import com.damu.entity.Users;
@WebServlet("/index")
public class UersFindServlet extends HttpServlet{
//当访问index时,会映射到servlet,然后调用这里的方法,然后跳转到index页面
private UserDao userDao=new UserDao();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
this.doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
//得到User的查询结果list
List<Users> list=userDao.findAll();
//将list作为一个属性值方便获取
req.setAttribute("UsersList", list);
//然后将list发送到页面
req.getRequestDispatcher("index.jsp").forward(req, resp);
}
}
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>慕课网用户管理中心</title>
<link rel="stylesheet" href="lib/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<script src="lib/2.2.4/jquery-1.12.4.min.js"></script>
<script src="lib/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="page-header">
<h1>慕课网后台管理系统 <small>用户数据管理中心</small></h1>
</div>
</div>
<div class="row">
<div class="jumbotron">
<h1>MyBatis基础入门课程!</h1>
<p>通过一个项目来完成基础部分的学习</p>
<p><a class="btn btn-primary btn-lg" href="#">查看更多,请上慕课网</a></p>
<p><a class="btn btn-primary btn-lg" href="">新增用户</a></p>
</div>
</div>
<div class="row">
<table class="table table-hover table-striped">
<tr>
<th>用户编号</th>
<th>登录账号</th>
<th>用户昵称</th>
<th>邮箱</th>
<th>联系方式</th>
<th>账号创建时间</th>
<th>用户状态</th>
<th>操作</th>
<c:forEach items="${UsersList}" var="user">
<tr>
<td>${user.id}</td>
<td>${user.username}</td>
<td>${user.nickname}</td>
<td>${user.email}</td>
<td>${user.phone}</td>
<td>${user.createTime}</td>
<c:if test="${user.userStatus == 0}">
<td>正常</td>
</c:if>
<c:if test="${user.userStatus == 1}">
<td>锁定</td>
</c:if>
<c:if test="${user.userStatus == 2}">
<td>删除</td>
</c:if>
<td>
<a>查看</a>
<a>修改</a>
<a>删除</a>
</td>
</tr>
</c:forEach>
</tr>
</table>
</div>
</div>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>mb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>home.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

正在回答 回答被采纳积分+1
相似问题
登录后可查看更多问答,登录/注册
- 参与学习 人
- 提交作业 277 份
- 解答问题 4297 个
Java数据库开发的必备技能,从流行的MySQL数据库开始,到Java原生的数据库管理接口JDBC的使用,再到常用的数据持久化框架MyBatis,让你向Java工程师的目标又迈进了一步!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星