我用的eclipse,建立的项目运行,照着视频抄的,出问题了,急求帮助
web.xml
<?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>MicroMessage</display-name> <welcome-file-list> <!-- <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> --> <welcome-file>index.jsp</welcome-file> <!-- <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> --> </welcome-file-list> <servlet> <!-- 接下来要跳转到一个列表页面 --> <servlet-name>ListServlet</servlet-name> <!-- servlet类 --> <servlet-class>com.imooc.servlet.ListServlet</servlet-class> </servlet> <!-- 添加映射 --> <servlet-mapping> <servlet-name>ListServlet</servlet-name> <url-pattern>/List.action</url-pattern> </servlet-mapping> </web-app>
ListServlet.java
package com.imooc.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * 列表页面初始化控制 * * * @SuppressWarnings("serial") 类可序列化的原因 */ @SuppressWarnings("serial") public class ListServlet extends HttpServlet { // 实现doGet方法 @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.getRequestDispatcher("/WEB-INF/jsp/back/list.jsp").forward(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub this.doGet(req, resp); } }
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" 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" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="<%=basePath%>"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> </body> </html>
list.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% String path=request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; <base href="<%=basePath%>"> %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" /> <title>内容列表页面</title> <link href="<%=basePath %>resources/css/all.css" rel="stylesheet" type="text/css" /> </head> <body style="background: #e1e9eb;"> <form action="" id="mainForm" method="post"> <div class="right"> <div class="current"> 当前位置:<a href="javascript:void(0)" style="color: #6E6E6E;">内容管理</a> > 内容列表 </div> <div class="rightCont"> <p class="g_title fix"> 内容列表 <a class="btn03" href="#">新 增</a> <a class="btn03" href="#">删 除</a> </p> <table class="tab1"> <tbody> <tr> <td width="90" align="right">演示字段1:</td> <td><input type="text" class="allInput" value="" /></td> <td width="90" align="right">演示字段2:</td> <td><input type="text" class="allInput" value="" /></td> <td width="85" align="right"><input type="submit" class="tabSub" value="查 询" /></td> </tr> </tbody> </table> <div class="zixun fix"> <table class="tab2" width="100%"> <tbody> <tr> <th><input type="checkbox" id="all" onclick="#" /></th> <th>序号</th> <th>演示字段1</th> <th>演示字段2</th> <th>操作</th> </tr> <tr> <td><input type="checkbox" /></td> <td>1</td> <td>演示值1</td> <td>演示值2</td> <td><a href="#">修改</a> <a href="#">删除</a> </td> </tr> <tr style="background-color: #ECF6EE;"> <td><input type="checkbox" /></td> <td>2</td> <td>演示值1</td> <td>演示值2</td> <td><a href="#">修改</a> <a href="#">删除</a> </td> </tr> <tr> <td><input type="checkbox" /></td> <td>3</td> <td>演示值1</td> <td>演示值2</td> <td><a href="#">修改</a> <a href="#">删除</a> </td> </tr> <tr style="background-color: #ECF6EE;"> <td><input type="checkbox" /></td> <td>4</td> <td>演示值1</td> <td>演示值2</td> <td><a href="#">修改</a> <a href="#">删除</a> </td> </tr> </tbody> </table> <div class='page fix'> 共 <b>4</b> 条 <a href='###' class='first'>首页</a> <a href='###' class='pre'>上一页</a> 当前第<span>1/1</span>页 <a href='###' class='next'>下一页</a> <a href='###' class='last'>末页</a> 跳至 <input type='text' value='1' class='allInput w28' /> 页 <a href='###' class='go'>GO</a> </div> </div> </div> </div> </form> </body> </html>