仿照慕課中的報表項目http://www.xianlaiwan.cn/learn/375? 但是點擊生成報表 顯示404錯誤這是JSP代碼<%@ page language="java" import="java.util.*,beans.*" 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"><html>? <head>? ? <base href="<%=basePath%>">? ??? ? <title>My JSP 'index.jsp' starting page</title> <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"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <style type="text/css"> .table-c {border-right: solid black;border-bottom: solid black}? .table-c td{border-left: solid black;border-top: solid black;padding: 10px 10px} </style>? </head>??? <body>? ? <form action="servlet/MyServlet" method="post">? ? <input type="submit" value="生成報表">? ? </form>? ??? ? <table class="table-c">? ? <tr class="trcss">? ? <td colspan="6" align="center"><strong>亞思晟公司職員信息表</strong></td>? ? </tr>? ? <tr>? ? <td>編號</td>? ? <td>用戶名</td>? ? <td>公司名稱</td>? ? <td>公司地址</td>? ? <td>公司電話</td>? ? <td>電子郵件</td>? ? </tr>? ??? ? <%? ? List list = null;? ? if(session.getAttribute("chart")!=null){? ? list = (List)session.getAttribute("chart"); //取到servlet中的list? ? if(list.size()>0){? ? int temp = 0;? ? UserInfo userinfo;? ? for(int i=0;i<1;i++){? ? userinfo = new UserInfo();?? ? userinfo = (UserInfo)list.get(i);? ? %> <tr> <td><%=userinfo.getId() %></td> <td><%=userinfo.getFullname() %></td> <td><%=userinfo.getCompanyname() %></td> <td><%=userinfo.getCompanyaddress() %></td> <td><%=userinfo.getTel()%></td> <td><%=userinfo.getEmail() %></td> </tr> <% }? ? }? ? }? ? ?%>? ? </table>? </body></html>這是 servlet代碼?package servlet;import java.io.IOException;import java.io.PrintWriter;import java.util.List;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import JDBCservice.Service;public class MyServlet extends HttpServlet { /** * Constructor of the object. */ public MyServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. *? * @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 doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); out.println("<HTML>"); out.println(" ?<HEAD><TITLE>A Servlet</TITLE></HEAD>"); out.println(" ?<BODY>"); out.print(" ? ?This is "); out.print(this.getClass()); out.println(", using the GET method"); out.println(" ?</BODY>"); out.println("</HTML>"); out.flush(); out.close(); } /** * 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 { List list; Service service = new Service(); list = service.getChart(); request.getSession().setAttribute("chart",list); response.sendRedirect("index.jsp"); } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here }}這是XML中的代碼<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">? <display-name></display-name>? <servlet>? ? <description>This is the description of my J2EE component</description>? ? <display-name>This is the display name of my J2EE component</display-name>? ? <servlet-name>MyServlet</servlet-name>? ? <servlet-class>servlet.MyServlet</servlet-class>? </servlet>? <servlet-mapping>? ? <servlet-name>MyServlet</servlet-name>? ? <url-pattern>/servlet/MyServlet</url-pattern>? </servlet-mapping>? <welcome-file-list>? ? <welcome-file>index.jsp</welcome-file>? </welcome-file-list></web-app>請問哪里出錯了?????????謝謝?。。。。?!
簡單的報表項目傳值不顯示
frank_mojito
2017-03-13 17:55:15