河北省重大技術需求徵集系統原型

O_O似曾相識發表於2022-03-05

該專案今天全部完成套用了一個框架比較生疏,許多東西以後會完善的。

今天完善過程遇到很多問題後面會一個個列舉並寫出解決方法:

1、驗證碼問題(checkcode.java、login.jsp、login.java)

在後續程式碼中(checkcode.java、login.jsp、login.java)三部分展示。checkcode.java生成驗證碼圖片在login.html中顯示圖片並設定點選事件,login.java中驗證驗證碼的正確性,

2、框架頁面點選跳轉不存在於一個頁面問題(程式碼在indexmain.jsp中)

用到了HTML中的<iframe標籤>,標籤定義及使用說明<iframe> ;標籤規定一個內聯框架。一個內聯框架被用來在當前 HTML 文件中嵌入另一個文件。然後在點選連結中加入 target="mainframe"

target定義和用法

HTML5 不支援 <link> target 屬性。target 屬性規定在哪個視窗或框架中載入被連結文件。語法<link target="_blank|_self|_parent|_top|framename">

描述
_blank 在新視窗中開啟被連結文件。
_self 預設。在相同的框架中開啟被連結文件。
_parent 在父框架集中開啟被連結文件。
_top 在整個視窗中開啟被連結文件。
framename 在指定的框架中開啟被連結文件。

3、後臺資料如何在HTMl顯示

這一塊用到了,html+ajax+servlet展示後臺資料大家可以看大佬(5條訊息) html+ajax+servlet展示後臺資料_不吃豆芽兒的部落格-CSDN部落格

4、文字框輸入500超出範圍(zhengji.html)

這個問題取決於資料庫的定義型別剛開始我定義的varchar型別後面檢視資料採用text型別有的推薦使用longtext我的不能新增長度就直接過了,之後將文字框換為文字域該問題也就解決了

5、eclipse中jsp檔案修改瀏覽器沒有同步,問題之解決

jsp檔案改了,但是瀏覽器顯示的效果都沒有變化。刪了cookies,重啟Tomcat都沒解決。(有時可以解決)雖然只是小問題,但確實讓人討厭。

個人經驗:碰到這種情況,右擊Tomcat伺服器,clean,再start一下就可以了!

其餘便是一些小問題了,下面我先呈上本次專案的所有程式碼以及結構框架

前端

indexmain.jsp

<%@page import="util.util"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="Bean.zhengjis"%>
<%@page import="Dao.dao"%>
<%@page import="javax.servlet.http.HttpSession"%>
<%@page import="javax.servlet.http.HttpServletRequest"%>
<%@page import="javax.servlet.http.HttpServletResponse"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <meta charset="UTF-8">
        <title>後臺使用者中心</title>
        <link rel="stylesheet" type="text/css" href="statics/css/iconfont.css" />
        <link rel="stylesheet" type="text/css" href="statics/css/style.css" />
        <link rel="stylesheet" type="text/css" href="static/css/app.css"></link>
    
    </head>

    <body>
            <% 
            HttpSession sess=request.getSession();
            String name=(String) sess.getAttribute("name");//學生姓名
            %>
        <div class="header">
            <div class="bar">
                <div class="w1200">
                    <span class="l">xxx網<font>使用者中心</font></span>
                    <span class="r"><a href="#"><i class="icon iconfont icon-dianyuan"></i>退出</a></span>
                </div>
            </div>
            <div class="user-info">
                <div class="w1200">
                    <div class="user-headface">
                        <img src="statics/images/user_face.jpg"/>
                    </div>
                    <div class="user-account">
                        <p class="tip">下午好,<%=name%></p>
                        <p class="account">
                            <span>帳戶名:<%=name%></span>
                        </p>
                </div>
            </div>
        </div></div>
        <div class="main w1200">
            <div class="left">    
            
                <ul>
                    <li>
                        <a href="zhengji.html" target="mainframe" class="active">
                            <i class="icon iconfont icon-lingdang"></i>
                            需求徵集
                        </a>
                    </li>
                    <li>
                        <a href="index.jsp?act=select2 "target="mainframe">
                            <i class="icon iconfont icon-fangzidichan"></i>
                            遊覽需求
                        </a>
                    </li>
                    <li>
                        <a href="index.jsp"target="mainframe">
                            <i class="icon iconfont icon-wenda"></i>
                            需求稽核
                        </a>
                    </li>
                    <li>
                        <a href="register.html">
                            <i class="icon iconfont icon-icon--"></i>
                            使用者註冊
                        </a>
                    </li>
                    <li>
                        <a href="mima.html">
                            <i class="icon iconfont icon-geren"></i>
                            修改密碼
                        </a>
                    </li>
                </ul>
            </div>
            <div class="right">
                <div class="tap">
                    <span>系統訊息</span>
                </div>
                  <div class="container-main">
            <iframe name="mainframe" src="work.jsp" frameborder="0"width="1000"height="500" ></iframe>
        </div>
        </div></div>
    </body>

</html>

login.java

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<title></title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
   var height=$(document).height();
   $('body').css('height',height);
   var mart=height-500;
   mart = mart/2;
   $('.loginBox').css('marginTop',mart);
})
</script>
<script>
        onload = function () {
            document.getElementById("img").onclick = function () {
                this.src = "CheckCode?time"+new Date().getTime();
            }
        }
    </script>
</head>
S
<body>
<form action="login" method="post">
<div class="loginBox">
  <h1>歡迎登陸</h1>
  <div class="item">
    <div class="icon"><img src="images/icon1.png" /></div>
    <div class="txt"><input name="username" type="text" placeholder="請輸入您的使用者名稱"/></div>
  </div>
  <div class="item">
    <div class="icon"><img src="images/icon2.png" /></div>
    <div class="txt"><input name="password1" type="password" placeholder="請輸入您的密碼"/></div>
  </div>
    <div class="item">
    <div class="icon"><img src="images/icon3.png" /></div>
    <div class="txt">
    <input type="text"  name="yanzhengma"placeholder="請輸入驗證碼"  >
    
     </div> 
      <div><img src="CheckCode" id="img" ></img></div>
  </div>
  <div class="item_3">
    <input name="submi1" type="submit" onclick="sublim()" value="安全登入" class="btn"/>
  </div>

  <div class="item_4">
    還沒有賬號?<a href="register.html">立即註冊</a>
  </div>
</div>
</from>
</body>
</html>

mima.java(修改密碼)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<title></title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
   var height=$(document).height();
   $('body').css('height',height);
   var mart=height-500;
   mart = mart/2;
   $('.loginBox').css('marginTop',mart);
})
</script>
</head>

<body>
<form action="mima" method="post">
<div class="loginBox">
  <h1>註冊</h1>
  <div class="item">
    <div class="icon"><img src="images/icon1.png" /></div>
    <div class="txt"><input name="yonghu" type="text" placeholder="請輸入您的使用者名稱"/></div>
  </div>
  <div class="item">
    <div class="icon"><img src="images/icon2.png" /></div>
    <div class="txt"><input name="password" type="password" placeholder="請輸入您的新密碼"/></div>
  </div>
   <div class="item">
    <div class="icon"><img src="images/icon2.png" /></div>
    <div class="txt"><input name="password1" type="password" placeholder="請再次輸入您的密碼"/></div>
  </div>
  <div class="item_3">
    <input name="" type="submit" value="修改" class="btn"/>
  </div>
  <div class="item_4">
    已註冊<a href="index.html">返回</a>
  </div>
</div>
</form>
</body>
</html>

register.java

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<title></title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
   var height=$(document).height();
   $('body').css('height',height);
   var mart=height-500;
   mart = mart/2;
   $('.loginBox').css('marginTop',mart);
})
</script>
</head>

<body>
<form action="register" method="post">
<div class="loginBox">
  <h1>註冊</h1>
  <div class="item">
    <div class="icon"><img src="images/icon1.png" /></div>
    <div class="txt"><input name="yonghu" type="text" placeholder="請輸入您的使用者名稱"/></div>
  </div>
  <div class="item">
    <div class="icon"><img src="images/icon2.png" /></div>
    <div class="txt"><input name="password" type="password" placeholder="請輸入您的密碼"/></div>
  </div>
   <div class="item">
    <div class="icon"><img src="images/icon2.png" /></div>
    <div class="txt"><input name="password1" type="password" placeholder="請再次輸入您的密碼"/></div>
  </div>
   <div class="item">
    <div class="icon"><img src="images/icon2.png" /></div>
    <div class="txt"><input name="id" id="id" type="text" placeholder="手機號碼" onblur="isCardNo(this.value)" />
    </div>
  </div>
     <div class="item">
    <div class="icon"><img src="images/icon2.png" /></div>
    <div class="txt"><input name="address" type="text" placeholder="所屬單位"/></div>
  </div>    

  <div class="item_3">
    <input name="" type="submit" value="註冊" class="btn"/>
  </div>
  <div class="item_4">
    已註冊<a href="login.html">我要登入</a>
  </div>
</div>
</form>
</body>
<script type="text/javascript">
function isCardNo(card) 
{ 
  var reg = /(^\d{11}$)/; 
   if(reg.test(card) === false) 
  { 
    alert("電話號碼不為11位"); 
    document.getElementById('id').value="";
  } 
}
</script>
</html>

work.jsp(無用東西可加可不加)

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>jQuery/HTML5/css3精美唯美圖片Y軸展示</title>
    
    <link rel="stylesheet" href="bbb/css/style.css">
    
</head>

<body>
   
    <div class="wrapper init">
        <ul class="content">
            <li class="item" >
                <div class="inner">
                    <div class="bjPic" ></div>
                    <div class="dir" >
                        <h2>那一瞬</h2>
                    </div>
                    <div class="showBox">
                        <div class="showBox-dir" >
                            <h2>  那一瞬,我飛昇成仙,不為長生,只為佑你平安喜樂</h2></a>
                           
                        </div>
                        <div class="close">

                        </div>
                    </div>
                </div>

            </li>
            <li class="item">
                <div class="inner">
                    <div class="bjPic"></div>
                    <div class="dir">
                        <h2>那一刻</h2>
                    </div>
                    <div class="showBox">
                        <div class="showBox-dir">
                            <h2>那一刻,我升起風馬,不為祈福,只為守候你的到來</h2>
                        </div>
                        <div class="close">

                        </div>
                    </div>
                </div>

            </li>
            <li class="item">
                <div class="inner">
                    <div class="bjPic"></div>
                    <div class="dir">
                        <h2>那一日</h2>
                    </div>
                    <div class="showBox">
                        <div class="showBox-dir">
                            <h2>那一日,我磨一砂石,不為修性,只為丟進你的心海</h2>
                        </div>
                        <div class="close">

                        </div>
                    </div>
                </div>

            </li>
            <li class="item">
                <div class="inner">
                    <div class="bjPic"></div>
                    <div class="dir">
                        <h2>那一夜</h2>
                    </div>
                    <div class="showBox">
                        <div class="showBox-dir">
                            <h2>那一夜,我徹宿低吟,不為參悟,只為尋你的氣息</h2>
                        </div>
                        <div class="close">

                        </div>
                    </div>
                </div>

            </li>
            <li class="item">
                <div class="inner">
                    <div class="bjPic"></div>
                    <div class="dir">
                        <h2>那一天</h2>
                    </div>
                    <div class="showBox">
                        <div class="showBox-dir">
                            <h2>那一天,閉目在經殿香霧中,驀然聽見,你頌經中的真言</h2>
                        </div>
                        <div class="close">

                        </div>
                    </div>
                </div>

            </li>
            <li class="item">
                <div class="inner">
                    <div class="bjPic"></div>
                    <div class="dir">
                        <h2>那一月</h2>
                    </div>
                    <div class="showBox">
                        <div class="showBox-dir">
                            <h2>那一月,我搖動所有經筒,不為超度,只為觸控你指尖</h2>
                        </div>
                        <div class="close">

                        </div>
                    </div>
                </div>

            </li>
            <li class="item">
                <div class="inner">
                    <div class="bjPic"></div>
                    <div class="dir">
                        <h2>那一年</h2>
                    </div>
                    <div class="showBox">
                        <div class="showBox-dir">
                            <h2>那一年,磕長頭匍匐在山路,不為覲見,只為貼著你的溫暖</h2>
                        </div>
                        <div class="close">

                        </div>
                    </div>
                </div>

            </li>
            <li class="item">
                <div class="inner">
                    <div class="bjPic"></div>
                    <div class="dir">
                        <h2>那一世</h2>
                    </div>
                    <div class="showBox">
                        <div class="showBox-dir">
                        <a href="index.jsp"></a>
                            <h2>那一世,轉山轉水轉佛塔,不為修來世,只為途中相見</h2>
                        </div>
                        <div class="close">

                        </div>
                    </div>
                </div>

            </li>
        </ul>
    </div>
    
    <script src="bbb/js/jquery.min.js"></script>
    <script src="bbb/js/index.js"></script>
    <script src="bbb/js/snowflake.js"></script>
    
</body>
</html>

zhengji.html(徵集資訊填報)

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<SCRIPT LANGUAGE="JavaScript">
        var strTime, strDate;
        function webClock()
        {
            var dNow = new Date();
            var dHours = dNow.getHours();
            var dMinutes = dNow.getMinutes();
            var dSeconds = dNow.getSeconds();
            strTime = dHours;
            strTime += ((dMinutes<10) ? ":0" : ":") + dMinutes;
            strTime += ((dSeconds<10) ? ":0" : ":") + dSeconds;
            clock.time.value = strTime;
            
            var dDate = dNow.getDate();
            var dMonth = dNow.getMonth() + 1;
            var dYear = dNow.getYear();
            strDate = dMonth;
            strDate += ((dDate<10) ? "/0" : "/") + dDate;
            strDate += "/" + dYear;
            clock.date.value = strDate;
            setTimeout("webClock()",1000);
        }
    </SCRIPT>
</head>    
</HTML>
<body ONLOAD="webClock()">
    <h1 class="callout" align="center">河北省重大技術需求徵集表</h1>
<form action="zhengji1" method="post"align="center" >
        <table class="wzc-table" border="1" cellspacing="0">
             <tr>
                <th>技術需求名稱:</th>
                <td><input type="text"  name="mingcheng" size="20" style="width:700px;height: 40px;"></td>
            </tr>
            <tr>
                <th>重大科技需求概述:</th>
            <td colspan="3">
             <textarea cols="100" rows="5"name="gaishu"></textarea>
        </td>
            </tr>
            <tr>
            <th>研究型別:</th>
                <td>
                <input type="checkbox" name="leixing" value="基礎研究 ">基礎研究 
                <input type="checkbox" name="leixing" value="應用研究">應用研究
                <input type="checkbox" name="leixing" value="試驗發展">試驗發展
                <input type="checkbox" name="leixing" value="研究發展與成果應用">研究發展與成果應用 
                <input type="checkbox" name="leixing" value="技術推廣與科技服務  ">技術推廣與科技服務  
           </td>
            </tr>
            <tr>
                <th>時間:</th>
                <td><input type="text"  name="date" size="20" style="width:700px;height: 40px;"></td>
            </tr>
          <tr>
          <th>技術需求合作模式:</th>
                   <td> 
                 <input type="radio" name="moshi" value="獨立開發">獨立開發 
                     <input type="radio" name="moshi" value="技術轉讓" checked>技術轉讓
                 <input type="radio" name="moshi" value="合作開發">合作開發
                     <input type="radio" name="moshi" value="技術入股">技術入股
                     </td>
                     </tr>
                      <tr>
                <th>計劃總投資</th>
                <td><input type="text"  name="touzi" size="20" style="width:700px;height: 40px;"></td>
            </tr>
            
            <tr >
            <td></td>
                <td ><input type="submit" value="提交" class="wzc-btn" style="width: 200px;"></td>
            </tr> 
            
        </table>
    </form>
</body>
</html>

index.jsp(顯示所有基本資料並不完善)

<%@page import="util.util"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="Bean.zhengjis"%>
<%@page import="Dao.dao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>展示資料</title>
 <link rel="stylesheet" href="./layui/css/layui.css"><script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
  <script> layui.use('form', function() { var form = layui.form; form.render(); }); </script>
</head>
<body>
<form action="select" method="post">
    <table class="layui-table">
    <colgroup>
    <col width="150">
    <col width="200">
    <col>
  </colgroup>
  <thead>
        <tr>
            <th>序號</th>
            <th>技術需求名稱</th>
            <th>提交日期</th>
            <th>需求狀態</th>
        </tr>
        </thead>
        <tbody>
    <%
        ArrayList <zhengjis> zhengjis = new ArrayList<zhengjis>();
        dao dao = new dao();
        int num=0;
            dao.showall(zhengjis);
            for (int i =0; i < zhengjis.size(); i++) {
                zhengjis A = zhengjis.get(i);    
                num+=1;
        %>
        <tr>
        <td><%=num%></td>
            <td><a href="select?mm=<%=A.getMingcheng()%>"><%=A.getMingcheng()%></a></td>
            <th><%=A.getDate() %></th>
                    <td><%=A.getShenghe()%></td>        
        </tr>
        <%
            }
        %>
        
        </tbody>
        
    </table>
</body>
</html>

index2.jsp(顯示查詢資訊此jsp檔案與index.jsp相關聯無法自己啟動會因為要從index.jsp獲取資料)

<%@page import="util.util"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="Bean.zhengjis"%>
<%@page import="Dao.dao"%>
<%@page import="servlet.shenhe"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>展示資料</title> <link rel="stylesheet" href="./layui/css/layui.css"><script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
  <script> layui.use('form', function() { var form = layui.form; form.render(); }); </script>
</head>
<body>
<form action="shenhe" method="post" align="center">
        <table class="layui-table">
    <colgroup>
    <col width="150">
    <col width="200">
    <col>
  </colgroup>
  <thead>
        <tr>
            <th>技術需求名稱</th>
            <th>重大科技需求概述</th>
            <th>研究型別</th>
            <th>技術需求合作模式</th>
            <th>計劃總投資</th>
        </tr>
        </thead>
        <tbody>
    <%
        ArrayList <zhengjis> zhengjis =(ArrayList<zhengjis>)request.getAttribute("zhengji");;
        
        int num=0;
            for (int i =0; i < zhengjis.size(); i++) {
                zhengjis A = zhengjis.get(i);    
        %>
        <tr>
        <td><%=A.getMingcheng()%></td>
        <td><%=A.getGaishu()%></td>
        <td><%=A.getLeixing() %></td>
        <td><%=A.getMoshi()%></td>    
        <td><%=A.getTouzi()%></td>    
        <td><a href="shenhe?mm=<%=A.getMingcheng()%>&nn=<%=1%>"><input type = "button" onclick = "btnRst_Click()" value = "稽核通過" ></a>
                        <script>
                            function btnRst_Click() 
                            {    
                                undefined
                                alert("稽核通過");
                            }
                        </script>                   
                </input></td>            
                    <td><a href="shenhe?mm=<%=A.getMingcheng()%>&nn=<%=0%>"><input type = "button" onclick = "btnRst_Click2()" value = "稽核不通過" >
                        <script>
                            function btnRst_Click2() 
                            {undefined
                                alert("稽核不通過");
                            }
                        </script>                   
                </input></td>    
        </tr>
        <%
            }
        %>
    </tbody>
    </table>
</body>
</html>

 

後端:

Bean包

user.java

package Bean;

public class user {
private String number;
private String password;
private String phone;
private String address;
public String getNumber() {
    return number;
}
public void setNumber(String number) {
    this.number = number;
}
public String getPassword() {
    return password;
}
public void setPassword(String password) {
    this.password = password;
}
public String getPhone() {
    return phone;
}
public void setPhone(String phone) {
    this.phone = phone;
}
public String getAddress() {
    return address;
}
public void setAddress(String address) {
    this.address = address;
}
}

zhengjis.java

package Bean;

public class zhengjis {
    private String mingcheng;
    private String gaishu;
    private String leixing;
    private String moshi;
    private String touzi;
    private String shenghe;
    private String date;
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    public String getMingcheng() {
        return mingcheng;
    }
    public void setMingcheng(String mingcheng) {
        this.mingcheng = mingcheng;
    }
    public String getShenghe() {
        return shenghe;
    }
    public void setShenghe(String shenghe) {
        this.shenghe = shenghe;
    }
    public String getGaishu() {
        return gaishu;
    }
    public void setGaishu(String gaishu) {
        this.gaishu = gaishu;
    }
    public String getLeixing() {
        return leixing;
    }
    public void setLeixing(String leixing) {
        this.leixing = leixing;
    }
    public String getMoshi() {
        return moshi;
    }
    public void setMoshi(String moshi) {
        this.moshi = moshi;
    }
    public String getTouzi() {
        return touzi;
    }
    public void setTouzi(String touzi) {
        this.touzi = touzi;
    }
    
}

Dao包下(工具類):

dao.java

package Dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import Bean.user;
import Bean.zhengjis;
import util.util;

public class dao {
    public void add(user A) throws ClassNotFoundException, SQLException {
        Connection connection = util.getConnection();
        String sql = "insert into user(number,password,phone,address) values(?,?,?,?)";
        PreparedStatement preparedStatement = null;
        try {
             //������䴫�����
             preparedStatement = connection.prepareStatement(sql);
           // preparedStatement = connection.prepareStatement(sql);
             preparedStatement.setString(1, A.getNumber());
             preparedStatement.setString(2, A.getPassword());
             preparedStatement.setString(3, A.getPhone());
             preparedStatement.setString(4, A.getAddress());
             preparedStatement.executeUpdate();
             } catch (SQLException e) {
                // TODO Auto-generated catch block
               e.printStackTrace();
            }finally {

            }
    }
    public void add1(zhengjis A) throws ClassNotFoundException, SQLException {
        Connection connection = util.getConnection();
        String sql = "insert into zhengji(mingcheng,gaishu,leixing,moshi,touzi,shenghe,shijian) values(?,?,?,?,?,?,?)";
        PreparedStatement preparedStatement = null;
        try {
             //������䴫�����
             preparedStatement = connection.prepareStatement(sql);
           // preparedStatement = connection.prepareStatement(sql);
             preparedStatement.setString(1, A.getMingcheng());
             preparedStatement.setString(2, A.getGaishu());
             preparedStatement.setString(3, A.getLeixing());
             preparedStatement.setString(4, A.getMoshi());
             preparedStatement.setString(5, A.getTouzi());
             preparedStatement.setString(6, A.getShenghe());
             preparedStatement.setString(7, A.getDate());
             preparedStatement.executeUpdate();
             } catch (SQLException e) {
                // TODO Auto-generated catch block
               e.printStackTrace();
            }finally {

            }
    }
    public void xiugaimima(String yonghu,String password2) throws ClassNotFoundException, SQLException {
        Connection connection = util.getConnection();
        String sql = " update user set password = ? where number = ?";
        PreparedStatement preparedStatement = null;
        try {
             //������䴫�����
             preparedStatement = connection.prepareStatement(sql);
           // preparedStatement = connection.prepareStatement(sql);
           
             preparedStatement.setString(1, password2);
             preparedStatement.setString(2, yonghu);
             preparedStatement.executeUpdate();
             } catch (SQLException e) {
                // TODO Auto-generated catch block
               e.printStackTrace();
            }finally {

            }}
        public void showall(ArrayList<zhengjis> ke) throws ClassNotFoundException, SQLException{
            
             String sql1 ="select * from zhengji";
              //������䴫�����
             Connection connection = util.getConnection();
                 try {
                     PreparedStatement ps = connection.prepareStatement(sql1);
                     ResultSet rs =  ps.executeQuery();
                     
                 while(rs.next()) {
                     System.out.println("1”");
                    zhengjis A = new zhengjis();
                    A.setMingcheng(rs.getString(1));
                    A.setShenghe(rs.getString(6));
                    A.setDate(rs.getString(7));
                     ke.add(A);
                   }
                 } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
          
      }
        public void showall1(ArrayList<zhengjis> ke) throws ClassNotFoundException, SQLException{
            
             String sql1 ="select * from zhengji";
              //������䴫�����
             Connection connection = util.getConnection();
                 try {
                     PreparedStatement ps = connection.prepareStatement(sql1);
                     ResultSet rs =  ps.executeQuery();
                     
                 while(rs.next()) {
                     System.out.println("1”");
                    zhengjis A = new zhengjis();
                    A.setMingcheng(rs.getString(1));
                    A.setGaishu(rs.getString(2));
                    A.setLeixing(rs.getString(3));
                    A.setMoshi(rs.getString(4));
                    A.setTouzi(rs.getString(5));
                    A.setShenghe(rs.getString(6));
                     ke.add(A);
                   }
                 } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
          
      }
        public void update(String mm,String result) throws ClassNotFoundException, SQLException {
            Connection connection = util.getConnection();
            String sql = "update zhengji set shenghe = ?  where    mingcheng = ?";
            PreparedStatement preparedStatement = null;
            try {
                 //������䴫�����
                 preparedStatement = connection.prepareStatement(sql);
               // preparedStatement = connection.prepareStatement(sql);
                 preparedStatement.setString(1,result);
                 preparedStatement.setString(2, mm);

                 preparedStatement.executeUpdate();
                 } catch (SQLException e) {
                    // TODO Auto-generated catch block
                   e.printStackTrace();
                }finally {

                }
        }
        public void select(ArrayList<zhengjis> zhengjis,String name) throws ClassNotFoundException, SQLException{
             String sql1 ="select * from zhengji where mingcheng = ?";
             Connection connection = util.getConnection();
                 try {
                     PreparedStatement ps = connection.prepareStatement(sql1);
                      ps.setString(1, name);
                     ResultSet rs =  ps.executeQuery();  
                 while(rs.next()) {
                     zhengjis A = new zhengjis();
                     
                     A.setGaishu(rs.getString(2));
                     A.setLeixing(rs.getString(3));
                     A.setMoshi(rs.getString(4));
                     A.setTouzi(rs.getString(5));
                     A.setMingcheng(rs.getString(1));
                     zhengjis.add(A);
                   }
                 } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
          
      }
//    }
//    public void add2(agent A) throws ClassNotFoundException, SQLException {
//        Connection connection = util.getConnection();
//        String sql = "insert into agent(AgentAddress,AgentName,AgentID,AgentPhone) values(?,?,?,?)";
//        PreparedStatement preparedStatement = null;
//        try {
//             //������䴫�����
//             preparedStatement = connection.prepareStatement(sql);
//           // preparedStatement = connection.prepareStatement(sql);
//             preparedStatement.setString(1, A.getAgentAddress());
//             preparedStatement.setString(2, A.getAgentName());
//             preparedStatement.setString(3, A.getAgentID());
//             preparedStatement.setString(4, A.getAgentPhone());
//             preparedStatement.executeUpdate();
//             } catch (SQLException e) {
//                // TODO Auto-generated catch block
//               e.printStackTrace();
//            }finally {
//
//            }
//    }
}

servlet包下:

checkcode.java:這個檔案中是我遇到的第一個問題驗證碼,主要生成驗證碼的圖片再通過session獲取生成驗證碼資料在login.java裡進行與前端的資料比較

package servlet;

import javax.imageio.ImageIO;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;

@WebServlet(name = "CheckCode", value = "/CheckCode")
public class CheckCode extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //建立一個物件
        int width = 100;
        int height = 50;
        BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_3BYTE_BGR);
        //填充背景顏色
        Graphics g = image.getGraphics();//畫筆
        g.setColor(Color.cyan);//設定畫筆顏色
        g.fillRect(0,0,width,height);
        //畫邊框
        g.setColor(Color.black);
        g.drawRect(0,0,width-1,height-1);
        //隨機碼
        String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        Random ran = new Random();
        StringBuilder sb = new StringBuilder();
        for(int i=1;i<=4;i++){
            int index = ran.nextInt(str.length());
            char ch = str.charAt(index);
            sb.append(ch);
            g.drawString(ch+"",width/5*i,height/2);
        }
        String checkCode_session = sb.toString();
        //將驗證碼存入session
        request.getSession().setAttribute("checkCode_session",checkCode_session);
        //隨機劃線
        g.setColor(Color.BLUE);
        for(int i=1;i<4;i++){
            int x1 = ran.nextInt(width);
            int y1 = ran.nextInt(height);

            int x2 = ran.nextInt(width);
            int y2 = ran.nextInt(height);
            g.drawLine(x1,y1,x2,y2);
        }
        //圖片輸出
        ImageIO.write(image,"png",response.getOutputStream());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}

login.java:這個登入我加入了一些賬號、密碼、驗證碼是否存在是否正確並給出相應的結果。

package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.swing.WindowConstants;

import Bean.user;
import util.util;

/**
 * Servlet implementation class register
 */
@WebServlet("/login")
public class login extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public login() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request,response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
                // TODO Auto-generated method stub
                        request.setCharacterEncoding("utf-8");
                        //������Ӧ���ı�����
                        int index=-1;
                        response.setContentType("text/html;charset=utf-8");//設定字符集
                        String usernames = request.getParameter("username");
                        String passwords=request.getParameter("password1");
                        String works=request.getParameter("work");
                        String verifyc  = request.getParameter("yanzhengma");
                        HttpSession sess=request.getSession();
                        String name11=(String) sess.getAttribute("checkCode_session");//驗證碼
                        System.out.println(name11);
                        String svc =(String) request.getSession().getAttribute("sessionverify");
                        PrintWriter out=response.getWriter();
                        HttpSession session=request.getSession();
                        session.setAttribute("name", usernames);//獲取登入者資訊
                        Connection connection = null;
                        int i=0;int count=0;
            
                        String username1[]=new String[50];
                        String password2[]=new String[50];
                        String shenfen1[]=new String[50];
                        try {
                            connection = util.getConnection();
                        } catch (ClassNotFoundException | SQLException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        PreparedStatement pre = null;
                        try {
                            pre = connection.prepareStatement("select * from user");
                        } catch (SQLException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }
                        ResultSet set = null;
                        try {
                            set = pre.executeQuery("select * from user");
                        } catch (SQLException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } 
                        try {
                            while(set.next())
                            {
                                username1[i]=set.getString("number");
                                password2[i]=set.getString("password");
                                i++;
                                count++;
                            }
                        } catch (SQLException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }
                        if(verifyc.equals(name11))
                        {
                            System.out.println("驗證碼");
                        
                        for(int j=0;j<count;j++) {
                        if(username1[j].equals(usernames))
                        {
                            
                            System.out.println("dasdasd");
                            if(password2[j].equals(passwords))
                            {
                                System.out.println("shuichen");
                                    index=1;
                                    response.sendRedirect("indexmain.jsp");
                            }
                            else
                            {
                    
                                System.out.println("chen");
                                out.print("<script>alert('密碼錯誤');window.location.href='login.html'</script>");
                            }
                        }
                        else 
                        {
                            System.out.println("huo");
                            out.print("<script>alert('輸入賬號不存在請重新輸入');window.location.href='login.html'</script>");
                        }
                        }
                        
                        }
                        else
                        {
                            out.print("<script>alert('驗證碼錯誤請重新輸入');window.location.href='login.html'</script>");
                        }
//                        System.out.println(number);
            }}

mima.java(這個時用來修改密碼的其中包括密碼比較等)

package servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.dao;
import util.util;
import Bean.user;
/**
 * Servlet implementation class dengji
 */
@WebServlet("/mima")
public class mima extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public mima() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    request.setCharacterEncoding("utf-8");
    //������Ӧ���ı�����
    response.setContentType("text/html;charset=utf-8");//������Ӧ����,����ֹ��������
System.out.println("dasdasd");
String yonghu=request.getParameter("yonghu");
String password=request.getParameter("password");
String password1=request.getParameter("password1");
if(password.equals(password1)) {
    
    
Connection connection = null;
int i=0;int count=0;
String username1[]=new String[50];
dao A=new dao();
try {
    connection = util.getConnection();
} catch (ClassNotFoundException | SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
PreparedStatement pre = null;
try {
    pre = connection.prepareStatement("select * from user");
} catch (SQLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}
ResultSet set = null;
try {
    set = pre.executeQuery("select * from user");
} catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} 
try {
    while(set.next())
    {
        username1[i]=set.getString("number");
        System.out.println(username1[i]);
        i++;
        count++;
    }
} catch (SQLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}
for(int j=0;j<count;j++) {
    if(username1[j].equals(yonghu))
    {
            
                try {
                    A.xiugaimima(yonghu, password1);
                } catch (ClassNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
    }
}}
else
{
    response.getWriter().print("<script>alert('輸入密碼錯誤請重新輸入!');window.location.href='mima.html'</script>");
}
}}

register.java(註冊)

package servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Dao.dao;
import Bean.user;
/**
 * Servlet implementation class dengji
 */
@WebServlet("/register")
public class register extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public register() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        request.setCharacterEncoding("utf-8");
        //������Ӧ���ı�����
        response.setContentType("text/html;charset=utf-8");//������Ӧ����,����ֹ��������
        
        dao A =new dao();
        String password = request.getParameter("password");
        String username=request.getParameter("yonghu");
        String phone=request.getParameter("id");
        String password1=request.getParameter("password1");
        String address=request.getParameter("address");
        if(password.equals(password1))
        {user B = new user();
        B.setNumber(username);
        B.setPassword(password);
        B.setPhone(phone);
        B.setAddress(address);
        try {
            A.add(B);
        } catch (ClassNotFoundException | SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
            
        }
        else {
            System.out.println("密碼");
            response.getWriter().print("<script>alert('輸入密碼錯誤請重新輸入!');window.location.href='register.html'</script>");
        
    }
    }
}

select.java

package servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Bean.zhengjis;

import Dao.dao;
import util.util;

/**
 * Servlet implementation class add
 */
@WebServlet("/select")
public class select extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public select() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request,response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        
        // TODO Auto-generated method stub
            request.setCharacterEncoding("utf-8");
            
            response.setContentType("text/html;charset=utf-8");
            String mingcheng = request.getParameter("mm");;
            ArrayList <zhengjis> zhengji = new ArrayList<zhengjis>();
            dao dao=new dao();
            if(mingcheng!=null)
            {
                try {
                    dao.select(zhengji,mingcheng);
                } catch (ClassNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                request.setAttribute("zhengji",zhengji);//setAttribute() 方法新增指定的屬性,併為其賦指定的值。
                request.getRequestDispatcher("index2.jsp").forward(request, response);
                
            }
            else {
                response.getWriter().write("查詢資料不存在請重新輸入。");
            }
//            else if(number!=null)    {
//                    try {
//                        dao.select1(book,number);
//                    } catch (ClassNotFoundException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    } catch (SQLException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    }
//                    request.setAttribute("people",people);
//                    request.getRequestDispatcher("chakan.jsp").forward(request, response);
//                }
//            else if(minzu!=null)    {
//                    try {
//                        dao.select4(people,minzu);
//                    } catch (ClassNotFoundException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    } catch (SQLException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    }
//                    request.setAttribute("people",people);
//                    request.getRequestDispatcher("chakan.jsp").forward(request, response);
//                }
//                else     {
//                    try {
//                        dao.select5(people,jiaoyuchengdu);
//                    } catch (ClassNotFoundException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    } catch (SQLException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    }
//                    request.setAttribute("people",people);
//                    request.getRequestDispatcher("chakan.jsp").forward(request, response);
//                }
        
                
            }}

shenhe.java對資料進行稽核

package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.swing.WindowConstants;

import Bean.user;
import Bean.zhengjis;
import util.util;
import Dao.dao;
/**
 * Servlet implementation class sehnhe
 */
@WebServlet("/shenhe")
public class shenhe extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public shenhe() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
                request.setCharacterEncoding("utf-8");
                //������Ӧ���ı�����
                response.setContentType("text/html;charset=utf-8");//������Ӧ����,����ֹ��������
                System.out.println("chen");
                String mm=request.getParameter("mm");
                String nn=request.getParameter("nn");
                dao A=new dao();
                String result="";
                System.out.println(mm);
                if(nn.equals("1"))
                {
                    result="通過";
                }
                else
                {
                    result="未通過";
                }
                zhengjis B = new zhengjis();
                
                try {
                    A.update(mm,result);
                     
                } catch (ClassNotFoundException | SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                response.sendRedirect("index.jsp");
            }
    }

zhengji1.java(相當於上傳一個資料表了)

package servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Bean.zhengjis;
import Dao.dao;
/**
 * Servlet implementation class zhengji1
 */
@WebServlet("/zhengji1")
public class zhengji1 extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public zhengji1() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        request.setCharacterEncoding("utf-8");
        //������Ӧ���ı�����
        response.setContentType("text/html;charset=utf-8");//������Ӧ����,����ֹ��������
        
        dao A =new dao();
        String mingcheng = request.getParameter("mingcheng");
        String gaishu=request.getParameter("gaishu");
        String leixing=request.getParameter("leixing");
        String [] lei  = request.getParameterValues("leixing");
         leixing = Arrays.toString(lei);
        String moshi=request.getParameter("moshi");
        String touzi=request.getParameter("touzi");
        String shijian=request.getParameter("date");
//        System.out.println();
        System.out.println(mingcheng);
        String shenghe="未稽核";
        zhengjis B = new zhengjis();
        System.out.println("213123");
            B.setMingcheng(mingcheng);
            B.setGaishu(gaishu);
            B.setLeixing(leixing);
            B.setTouzi(touzi);
            B.setMoshi(moshi);
            B.setShenghe(shenghe);
            B.setDate(shijian);
        try {
                A.add1(B);
        } catch (ClassNotFoundException | SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        response.getWriter().print("<script>alert('徵集上傳成功請等候訊息');window.location.href='index.html'</script>");
        }
        
    }

 這是本次專案檔案以及css樣式大家可以提取

連結:https://pan.baidu.com/s/1gHHWfzzsG6fwdv1Mmdv10A
提取碼:jyt9

相關文章