第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

簡(jiǎn)單的報(bào)表項(xiàng)目傳值不顯示

簡(jiǎn)單的報(bào)表項(xiàng)目傳值不顯示

frank_mojito 2017-03-13 17:55:15
仿照慕課中的報(bào)表項(xiàng)目http://idcbgp.cn/learn/375? 但是點(diǎn)擊生成報(bào)表 顯示404錯(cuò)誤這是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="生成報(bào)表">? ? </form>? ??? ? <table class="table-c">? ? <tr class="trcss">? ? <td colspan="6" align="center"><strong>亞思晟公司職員信息表</strong></td>? ? </tr>? ? <tr>? ? <td>編號(hào)</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>請(qǐng)問(wèn)哪里出錯(cuò)了?????????謝謝?。。。。?!
查看完整描述

1 回答

已采納
?
夢(mèng)影劍魂

TA貢獻(xiàn)66條經(jīng)驗(yàn) 獲得超21個(gè)贊

肯定是訪問(wèn)路徑?jīng)]寫對(duì),找不到指定資源文件。你試下在servlet中dopost()方法的response.sendRedirect("index.jsp");重定向的路徑前加個(gè)/,看下可以嗎

查看完整回答
反對(duì) 回復(fù) 2017-03-13
  • frank_mojito
    frank_mojito
    也不行,但是項(xiàng)目名/后就ok了!已經(jīng)搞定了,謝謝!
  • 1 回答
  • 0 關(guān)注
  • 1060 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)