<PRE class=html name=code><!DOCTYPE html PUBLIC //WC//DTD HTML Transitional//EN >
<html>
<head>
<meta httpequiv=ContentType content=text/html; charset=UTF>
<title>網絡通訊錄</title>
</head>
<body>
<form action=successdo method=post>
<table>
<tr><td><div>用戶名:</div></td>
<td><input type=text name=username maxlength=></td>
</tr>
<tr><td><div >密碼:</div></td>
<td><input type=password name=password maxlength=></td>
</tr>
</table>
<input type=submit name=Submit value=提交>
</form>
<a >沒有注冊請點這裡</a>
</body>
</html></PRE>
DOCTYPE html PUBLIC //WC//DTD HTML Transitional//EN >
<html>
<head>
<meta httpequiv=ContentType content=text/html; charset=UTF>
<title>網絡通訊錄</title>
</head>
<body>
<form action=successdo method=post>
<table>
<tr><td><div>用戶名:</div></td>
<td><input type=text name=username maxlength=></td>
</tr>
<tr><td><div >密碼:</div></td>
<td><input type=password name=password maxlength=></td>
</tr>
</table>
<input type=submit name=Submit value=提交>
</form>
<a >沒有注冊請點這裡</a>
</body>
</html>
<!DOCTYPE html PUBLIC //WC//DTD HTML Transitional//EN >
<html>
<head>
<meta httpequiv=ContentType content=text/html; charset=UTF>
<title>網絡通訊錄</title>
</head>
<body>
<form action=successdo method=post>
<table>
<tr><td><div>用戶名:</div></td>
<td><input type=text name=username maxlength=></td>
</tr>
<tr><td><div >密碼:</div></td>
<td><input type=password name=password maxlength=></td>
</tr>
</table>
<input type=submit name=Submit value=提交>
</form>
<a >沒有注冊請點這裡</a>
</body>
</html>
//注冊界面
//注冊界面
<!DOCTYPE html PUBLIC //WC//DTD HTML Transitional//EN >
<html>
<head>
<meta httpequiv=ContentType content=text/html; charset=UTF>
<title>注冊界面</title>
</head>
<body>
請填寫注冊信息
<form method=post action=logindo>
<table width=% border=>
<tr>
<td width=%><div align=left>請輸入用戶名:</div></td>
<td width=%><input name=username type=text maxlength=></td>
</tr>
<tr>
<td width=%><div align=left>請輸入性別:</div></td>
<td width=%><input name=sex type=text maxlength=></td>
</tr>
<tr>
<td><div align=left>請輸入密碼</div></td>
<td><input type=password name=password></td>
</tr>
<tr>
<td><div align=left>密碼確認</div></td>
<td><input type=password name=password></td>
</tr>
<tr>
<td width=%><div align=left>請輸入真實姓名:</div></td>
<td width=%><input name=realName type=text maxlength=></td>
</tr>
<tr>
<td width=%><div align=left>請輸入學校名稱:</div></td>
<td width=%><input name=school type=text maxlength=></td>
</tr>
<tr>
<td width=%><div align=left>請輸入家庭地址:</div></td>
<td width=%><input name=address type=text maxlength=></td>
</tr>
<tr>
<td><div align=left>請輸入電子郵件</div></td>
<td><input type=text name=email></td>
</tr>
<tr>
<td width=%><div align=left>請輸入電話號碼:</div></td>
<td width=%><input name=phone type=text maxlength=></td>
</tr>
</table>
<p>
<input type=submit name=submit value=提交>
<input type=reset name=submit value=重設>
</p>
<p> </p>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC //WC//DTD HTML Transitional//EN >
<html>
<head>
<meta httpequiv=ContentType content=text/html; charset=UTF>
<title>注冊界面</title>
</head>
<body>
請填寫注冊信息
<form method=post action=logindo>
<table width=% border=>
<tr>
<td width=%><div align=left>請輸入用戶名:</div></td>
<td width=%><input name=username type=text maxlength=></td>
</tr>
<tr>
<td width=%><div align=left>請輸入性別:</div></td>
<td width=%><input name=sex type=text maxlength=></td>
</tr>
<tr>
<td><div align=left>請輸入密碼</div></td>
<td><input type=password name=password></td>
</tr>
<tr>
<td><div align=left>密碼確認</div></td>
<td><input type=password name=password></td>
</tr>
<tr>
<td width=%><div align=left>請輸入真實姓名:</div></td>
<td width=%><input name=realName type=text maxlength=></td>
</tr>
<tr>
<td width=%><div align=left>請輸入學校名稱:</div></td>
<td width=%><input name=school type=text maxlength=></td>
</tr>
<tr>
<td width=%><div align=left>請輸入家庭地址:</div></td>
<td width=%><input name=address type=text maxlength=></td>
</tr>
<tr>
<td><div align=left>請輸入電子郵件</div></td>
<td><input type=text name=email></td>
</tr>
<tr>
<td width=%><div align=left>請輸入電話號碼:</div></td>
<td width=%><input name=phone type=text maxlength=></td>
</tr>
</table>
<p>
<input type=submit name=submit value=提交>
<input type=reset name=submit value=重設>
</p>
<p> </p>
</form>
</body>
</html>vi
<PRE class=html name=code>//下面是l文件是servlete裡面對類的映射這是我對我上面那幾個類的映射</PRE>
<PRE class=html name=code> </PRE>
<PRE class=html name=code><?xml version= encoding=UTF?>
<webapp xmlns:xsi=instance xmlns= xmlns:web=app__xsd xsi:schemaLocation= app__xsd id=WebApp_ID version=>
<displayname>NoteBook</displayname>
<contextparam>
<paramname>configurationfile</paramname>
<paramvalue>/WEBINF/hibernatecfgxml</paramvalue>
</contextparam>
<listener>
<listenerclass>controlSessionFactoryListener</listenerclass>
</listener>
<servlet>
<servletname>MessageView</servletname>
<servletclass>viewMessageView</servletclass>
</servlet>
<servletmapping>
<servletname>MessageView</servletname>
<urlpattern>/messagedo</urlpattern>
</servletmapping>
<servlet>
<servletname>select</servletname>
<servletclass>controlSelect</servletclass>
</servlet>
<servletmapping>
<servletname>select</servletname>
<urlpattern>/select</urlpattern>
</servletmapping>
<servlet>
<servletname>SuccessView</servletname>
<servletclass>viewSuccessView</servletclass>
</servlet>
<servletmapping>
<servletname>SuccessView</servletname>
<urlpattern>/successdo</urlpattern>
</servletmapping>
<servlet>
<servletname>Login</servletname>
<servletclass>controlLoginServlet</servletclass>
</servlet>
<servletmapping>
<servletname>Login</servletname>
<urlpattern>/logindo</urlpattern>
</servletmapping>
<welcomefilelist>
<welcomefile>l</welcomefile>
</welcomefilelist>
</webapp></PRE>
<PRE class=html name=code> </PRE>
<PRE class=html name=code>//這是hibernate的配置文檔我也給大家了不過有些地方要跟自己的電腦裡一樣才行我用的是mysql</PRE>
<PRE class=html name=code> </PRE>
<PRE class=html name=code><PRE class=html name=code><?xml version= encoding=utf?>
<!DOCTYPE hibernateconfiguration PUBLIC
//Hibernate/Hibernate Configuration DTD //EN
configurationdtd>
<hibernateconfiguration>
<sessionfactory>
<! 設置JDBC驅動 >
<property name=connectiondriver_class>commysqljdbcDriver</property>
<! 設置數據庫地址 >
<property name=connectionurl>jdbc:mysql://:/hibernate</property>
<! 數據庫用戶名 >
<property name=connectionusername>root</property>
<! 用戶密碼 >
<property name=connectionpassword>root</property>
<! 數據庫方言 >
<property name=dialect>orghibernatedialectMySQLDialect</property>
<! JDBC連接池大小 >
<property name=connectionpool_size></property>
<! 二級緩沖提供者設置NoCacheProvider表示禁用二級緩沖 >
<property name=cacheprovider_class>orghibernatecacheNoCacheProvider</property>
<! 將執行的SQL輸出到控制台 >
<property name=show_sql>true</property>
<! 格式化執行的SQL指令 >
<property name=format_sql>true</property>
<! 啟動時自動創建數據表 >
<property name=hbmddlauto>update</property>
<mapping resource=model/userhbmxml/>
</sessionfactory>
</hibernateconfiguration></PRE>
</PRE>
<PRE class=html name=code> </PRE>
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25999.html