データベースの接続
12175 ワード
データベースに接続します.
まずTomcatデータベースを開き、eclipseを使用してwebテキストを作成します.
dao層servlet層util層を確立します.それぞれのコードを書き込みます.ウェブサイト言語でウェブページjspを構築します.データベースに対応するテーブルを作成し、異なる名前を付けてeclipseの対応する属性の1つに対応することに注意します.最初のidプライマリ・キーはnull以外をインクリメントします.
まずTomcatデータベースを開き、eclipseを使用してwebテキストを作成します.
dao層servlet層util層を確立します.それぞれのコードを書き込みます.ウェブサイト言語でウェブページjspを構築します.データベースに対応するテーブルを作成し、異なる名前を付けてeclipseの対応する属性の1つに対応することに注意します.最初のidプライマリ・キーはnull以外をインクリメントします.
<code class="java string">"text/javascript"</code>
<code class="java plain">></code>
</div>
<div class="line number75 index74 alt2">
<code class="java plain">function check(){</code>
</div>
<div class="line number76 index75 alt1">
<code class="java spaces"> </code>
<code class="java plain">var username=document.getElementById(</code>
<code class="java string">"gs1"</code>
<code class="java plain">);</code>
</div>
<div class="line number77 index76 alt2">
<code class="java spaces"> </code>
<code class="java plain">var password=document.getElementById(</code>
<code class="java string">"gs2"</code>
<code class="java plain">);</code>
</div>
<div class="line number78 index77 alt1">
<code class="java spaces"> </code>
<code class="java plain">var number=document.getElementById(</code>
<code class="java string">"gs5"</code>
<code class="java plain">);</code>
</div>
<div class="line number79 index78 alt2">
<code class="java spaces"> </code>
<code class="java plain">var mail=document.getElementById(</code>
<code class="java string">"gs6"</code>
<code class="java plain">);</code>
</div>
<div class="line number80 index79 alt1">
<code class="java spaces"> </code>
<code class="java plain">var sReg = /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/; </code>
<code class="java comments">// </code>
</div>
<div class="line number81 index80 alt2">
<code class="java spaces"> </code>
<code class="java comments">// </code>
</div>
<div class="line number82 index81 alt1">
<code class="java spaces"> </code>
<code class="java keyword">if</code>
<code class="java plain">((username.value).length<</code>
<code class="java value">6</code>
<code class="java plain">||(username.value).length></code>
<code class="java value">12</code>
<code class="java plain">){</code>
</div>
<div class="line number83 index82 alt2">
<code class="java spaces"> </code>
<code class="java plain">alert(</code>
<code class="java string">' 6 12 , '</code>
<code class="java plain">);</code>
</div>
<div class="line number84 index83 alt1">
<code class="java spaces"> </code>
<code class="java plain">gs1.focus();</code>
</div>
<div class="line number85 index84 alt2">
<code class="java spaces"> </code>
<code class="java keyword">return</code>
<code class="java keyword">false</code>
<code class="java plain">;</code>
</div>
<div class="line number86 index85 alt1">
<code class="java spaces"> </code>
<code class="java plain">}</code>
</div>
<div class="line number87 index86 alt2">
<code class="java spaces"> </code>
<code class="java comments">// </code>
</div>
<div class="line number88 index87 alt1">
<code class="java spaces"> </code>
<code class="java keyword">if</code>
<code class="java plain">(/.*[\u4e00-\u9fa5]+.*$/.test(username.value)){</code>
</div>
<div class="line number89 index88 alt2">
<code class="java spaces"> </code>
<code class="java plain">alert(</code>
<code class="java string">' '</code>
<code class="java plain">);</code>
</div>
<div class="line number90 index89 alt1">
<code class="java spaces"> </code>
<code class="java plain">gs1.focus();</code>
</div>
<div class="line number91 index90 alt2">
<code class="java spaces"> </code>
<code class="java keyword">return</code>
<code class="java keyword">false</code>
<code class="java plain">;</code>
</div>
<div class="line number92 index91 alt1">
<code class="java spaces"> </code>
<code class="java plain">}</code>
</div>
<div class="line number93 index92 alt2">
<code class="java spaces"> </code>
<code class="java comments">// </code>
</div>
<div class="line number94 index93 alt1">
<code class="java spaces"> </code>
<code class="java keyword">if</code>
<code class="java plain">(!isNaN(username.value[</code>
<code class="java value">0</code>
<code class="java plain">])){</code>
</div>
<div class="line number95 index94 alt2">
<code class="java spaces"> </code>
<code class="java plain">alert(</code>
<code class="java string">' '</code>
<code class="java plain">);</code>
</div>
<div class="line number96 index95 alt1">
<code class="java spaces"> </code>
<code class="java plain">gs1.focus();</code>
</div>
<div class="line number97 index96 alt2">
<code class="java spaces"> </code>
<code class="java keyword">return</code>
<code class="java keyword">false</code>
<code class="java plain">;</code>
</div>
<div class="line number98 index97 alt1">
<code class="java spaces"> </code>
<code class="java plain">}</code>
</div>
<div class="line number99 index98 alt2">
<code class="java spaces"> </code>
<code class="java comments">// </code>
</div>
<div class="line number100 index99 alt1">
<code class="java spaces"> </code>
<code class="java keyword">if</code>
<code class="java plain">((password.value).length!=</code>
<code class="java value">8</code>
<code class="java plain">){</code>
</div>
<div class="line number101 index100 alt2">
<code class="java spaces"> </code>
<code class="java plain">alert(</code>
<code class="java string">' 8 '</code>
<code class="java plain">);</code>
</div>
<div class="line number102 index101 alt1">
<code class="java spaces"> </code>
<code class="java plain">gs2.focus();</code>
</div>
<div class="line number103 index102 alt2">
<code class="java spaces"> </code>
<code class="java keyword">return</code>
<code class="java keyword">false</code>
<code class="java plain">;</code>
</div>
<div class="line number104 index103 alt1">
<code class="java spaces"> </code>
<code class="java plain">}</code>
</div>
<div class="line number105 index104 alt2">
<code class="java spaces"> </code>
<code class="java comments">// 2018 </code>
</div>
<div class="line number106 index105 alt1">
<code class="java spaces"> </code>
<code class="java keyword">if</code>
<code class="java plain">(number.value<</code>
<code class="java string">"20180000"</code>
<code class="java plain">|| number.value></code>
<code class="java string">"20189999"</code>
<code class="java plain">)</code>
</div>
<div class="line number107 index106 alt2">
<code class="java spaces"> </code>
<code class="java plain">{</code>
</div>
<div class="line number108 index107 alt1">
<code class="java spaces"> </code>
<code class="java plain">alert(</code>
<code class="java string">" 2018 "</code>
<code class="java plain">); </code>
</div>
<div class="line number109 index108 alt2">
<code class="java spaces"> </code>
<code class="java plain">gs5.focus();</code>
</div>
<div class="line number110 index109 alt1">
<code class="java spaces"> </code>
<code class="java keyword">return</code>
<code class="java keyword">false</code>
<code class="java plain">;</code>
</div>
<div class="line number111 index110 alt2">
<code class="java spaces"> </code>
<code class="java plain">}</code>
</div>
<div class="line number112 index111 alt1">
</div>
<div class="line number113 index112 alt2">
<code class="java spaces"> </code>
<code class="java comments">// </code>
</div>
<div class="line number114 index113 alt1">
<code class="java spaces"> </code>
</div>
<div class="line number115 index114 alt2">
<code class="java spaces"> </code>
<code class="java comments">// </code>
</div>
<div class="line number116 index115 alt1">
<code class="java spaces"> </code>
<code class="java keyword">if</code>
<code class="java plain">(! sReg.test(mail.value)){ </code>
</div>
<div class="line number117 index116 alt2">
<code class="java spaces"> </code>
<code class="java plain">alert(</code>
<code class="java string">' '</code>
<code class="java plain">);</code>
</div>
<div class="line number118 index117 alt1">
<code class="java spaces"> </code>
<code class="java plain">gs6.focus();</code>
</div>
<div class="line number119 index118 alt2">
<code class="java spaces"> </code>
<code class="java keyword">return</code>
<code class="java keyword">false</code>
<code class="java plain">;</code>
</div>
<div class="line number120 index119 alt1">
<code class="java spaces"> </code>
<code class="java plain">} </code>
</div>
<div class="line number121 index120 alt2">
<code class="java plain">}</code>
</div>
<div class="line number122 index121 alt1">
<code class="java plain">