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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

404問題。打不開頁(yè)面!(內(nèi)附所有代碼&web.xml文件內(nèi)容)

問題見題。

web.xml如下

<web-app version="3.0"
?xmlns="http://java.sun.com/xml/ns/javaee"
?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
?xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
?http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
? <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>RegistServlet</servlet-name>
??? <servlet-class>servlet.RegistServlet</servlet-class>
? </servlet>

? <servlet-mapping>
??? <servlet-name>RegistServlet</servlet-name>
??? <url-pattern>/servlet/RegistServlet</url-pattern>
? </servlet-mapping>?
? <welcome-file-list>
??? <welcome-file>regist.jsp</welcome-file>
? </welcome-file-list>
</web-app>

···································································································

regist.jsp如下

<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">
? .label{
??? width: 20%?
? }
? .controler{
??? width: 80%?
? }
?? </style>
??
?? <script type="text/javascript" src="js/Calendar.js"></script>
? </head>
?
? <body>
? <h1>用戶d注冊(cè)</h1>
? <hr>
? <form name="registForm" action="servlet/RegistServlet">
? ?<table border="0" width="800" cellspacing="0" cellpadding="0">
? ?<tr>
? ??<td class="label">用戶名:</td>
? ??<td class="controler"><input type="text" name="username" /></td>
? ?</tr>
? ?<tr>
? ??<td class="label">密碼:</td>
? ??<td class="controler"><input type="password" name="userpass" /></td>
?</tr>
? ?<tr>
? ??<td class="label">確認(rèn)密碼:</td>
? ??<td class="controler"><input type="password" name="confirmpass" /></td>
?</tr>
? ?<tr>
? ??<td class="label">電子郵件:</td>
? ??<td class="controler"><input type="text" name="email" /></td>
?</tr>
? ?<tr>
? ??<td class="label">性別:</td>
? ??<td class="controler">
? ???<input type="radio" name="gender" value="Male" checked="checked" />男 <%-- checked="checked"表明默認(rèn)選中 --%>
? ???<input type="radio" name="gender" value="Female" />女
? ??</td>
? ?</tr>
? ?<tr>
? ??<td class="label">出生日期:</td>
???? <td class="controler">
???<input type="text" name="birthday"
???? ?id="control_date" size="10"
????? maxlength="10" onclick="new Calendar().show(this);"
???readonly="readonly" />
??? ?</td>
? ?</tr>
? ?<tr>
? ??<td class="label">愛好:</td>
??<td class="controler">
???<input type="checkbox" name="favorite" value="nba" />NBA &nbsp;
???<input type="checkbox" name="favorite" value="music" />音樂 &nbsp;
???<input type="checkbox" name="favorite" value="movie" />電影 &nbsp;
???<input type="checkbox" name="favorite" value="internet" />上網(wǎng) &nbsp;
??</td>
? ?</tr>
? ?<tr>
? ??<td>自我介紹:</td>
? ??<td class="controler">
???<textarea name="introduce" rows="10" cols="40"></textarea>
??</td>
? ?</tr>
? ?<tr>
??<td class="label">接受協(xié)議:</td>
??<td class="controler">
???<input type="checkbox" name="isAccept" value="true">是否接受霸王條款
??</td>
?</tr>
?<tr>
??<td colspan="2" align="center">
???<input type="submit" value="注冊(cè)"/>&nbsp;&nbsp;
???<input type="reset" value="取消"/>&nbsp;&nbsp;
??</td>
?</tr>
? ?</table>
? </form>?
? </body>
</html>

············································································································

username.jsp如下

<html>
? <head>
??? <base href="<%=basePath%>">
???
??? <title>My JSP 'userinfo.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">
? .title{
?? width: 30%;?
?? background-color: #CCC;
?? font-weight: bold;
? }
? .content{
????? width:70%;
????? background-color: #CBCFE5;
? }
?
?? </style>?
? </head>
?
? <body>
?<body>
??? <h1>用戶信息</h1>
??? <hr>
??? <center>?
??? <jsp:useBean id="regUser" class="com.entity.User" scope="session" />;
???? <table width="600" cellpadding="0" cellspacing="0" border="1">
??????? <tr>
????????? <td class="title">用戶名:</td>? <%-- name為實(shí)例化對(duì)象的名字,property為要取得的屬性 --%>
????????? <td class="content">&nbsp;<jsp:getProperty name="regUser" property="username"/></td>
??????? </tr>
??????? <tr>
????????? <td class="title">密碼:</td>
????????? <td class="content">&nbsp;<jsp:getProperty name="regUser" property="password"></td>
??????? </tr>
??????? <tr>
????????? <td class="title">性別:</td>
????????? <td class="content">&nbsp;<jsp:getProperty name="regUser" property="gender"/></td>
??????? </tr>
??????? <tr>
????????? <td class="title">E-mail:</td>
????????? <td class="content">&nbsp;<jsp:getProperty name="regUser" property="email"/></td>
??????? </tr>
??????? <tr>
????????? <td class="title">出生日期:</td>
????????? <td class="content">&nbsp;
?????? ??<%
?????? ???SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月DD日");
?????? ???String date = sdf.format(regUser.getBirthday());
?????? ??%>
?????? ??<%=date %>
????????? </td>
??????? </tr>
??????? <tr>
????????? <td class="title">愛好:</td>
????????? <td class="content">&nbsp;
????????? <%
????????? ?String[] favorite = regUser.getFavorites();
????????? ?for (String f:favorite){
????????? %>
????????? ??<%=f %>&nbsp;&nbsp;
????????? <%
????????? ?}
????????? %>
????????? </td>
??????? </tr>
??????? <tr>
????????? <td class="title">自我介紹:</td>
????????? <td class="content">&nbsp;<jsp:getProperty name="regUser" property="introduce"/></td>
??????? </tr>
??????? <tr>
????????? <td class="title">是否遵守協(xié)議:</td>
????????? <td class="content">&nbsp;<jsp:getProperty name="regUser" property="flag"/></td>
??????? </tr>
???? </table>
??? </center>
? </body>
</html>


·····························································································

RegistServlet如下

public class RegistServlet extends HttpServlet {


?public RegistServlet() {
??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 {

??doPost(request,response);
?}

?/**
? * 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 {

??User user = new User();
??String username,password,gender,email,introduce,isAccept;
??Date birthday;
??String[] favorite;
??SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月DD日hh:mm:ss");
??
??try{
???username = request.getParameter("username");
???password = request.getParameter("password");
???gender = request.getParameter("gender");
???email = request.getParameter("email");
???introduce = request.getParameter("introduce");
???birthday = sdf.parse(request.getParameter("birthday"));
???favorite = request.getParameterValues("favorite");
???isAccept = request.getParameter("isAccept");
???
???user.setAccept(isAccept.equals("true")?true:false);
???user.setBirthday(birthday);
???user.setEmail(email);
???user.setFavorites(favorite);
???user.setGender(gender);
???user.setIntroduce(introduce);
???user.setPassword(password);
???user.setUsername(username);
???
???//將成功注冊(cè)用戶保存到session
???request.getSession().setAttribute("regUser", user);
???//跳轉(zhuǎn)(轉(zhuǎn)發(fā))到成功頁(yè)面
???request.getRequestDispatcher("../userinfo.jsp").forward(request, response);
??}catch(Exception e){
???e.printStackTrace();
??}
?}

?/**
? * Initialization of the servlet. <br>
? *
? * @throws ServletException if an error occurs
? */
?public void init() throws ServletException {
??// Put your code here
?}

}

·······························································································

輸入路徑絕對(duì)沒錯(cuò)(不要告訴我這個(gè)了···)求解!

正在回答

2 回答

你應(yīng)該直接把老師的jsp文件拷進(jìn)來(lái)了,表單<form name="regForm" action="RegServlet" method="post" >

action要與你的配置文件中<url-pattern>/RegServlet</url-pattern>要相同,老師給的action是action="servlet/RegServlet",你需要改成自己的。


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

陷入編程無(wú)法自拔的江北 提問者

非常感謝?。?!
2016-11-10 回復(fù) 有任何疑惑可以回復(fù)我~
#2

天宇不看海

請(qǐng)問改成自己的哪個(gè)
2017-01-06 回復(fù) 有任何疑惑可以回復(fù)我~

求問怎么解決的啊,我也遇到404問題,謝謝

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

404問題。打不開頁(yè)面!(內(nèi)附所有代碼&web.xml文件內(nèi)容)

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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