5.4号团队冲刺(三)

5.4

燃尽图:5.4号团队冲刺(三)

 任务板:

5.4号团队冲刺(三)

 

每日照片:

5.4号团队冲刺(三)

今天的任务是完成失物招领表单和寻物启事表单的提交。在这个表单提交方面我们有一下设计。

由于失主对物品丢失的地点可能会不清楚,因此我们写了一些函数对表单文本框内容是否为空进行了判断。由此来实现信息的必填和可不填属性。同时,关于后期的功能我们有一个根据物品丢失时间进行查询的想法,因此我们要规定描述物品丢失时间段的时间格式,因此我们使用了datetime格式对时间的填写格式进行了限定。

表单提交的界面代码如下所示:

<div id="tabContent2"  class="tc"  style="display: none">

<table border="8">

        <tr align="center" valign="middle" bgcolor="#CCCCCC" height="22">

        <td>描述</td>

<td>地点</td>

<td>时间</td>

<td>拾到者联系方式</td>

      <%

        ResultSet jdrs=jddb.getAllRs();

        if(jdrs==null){

      %>

      <tr align="center" valign="middle"><td colspan="4">没有记录显示!</td>

      </tr>

      <%

        }

        else{

          while(jdrs.next()){

      %>

      <tr align="center" valign="middle" height="22">

        <td><%=jdrs.getString("name") %></td>    

        <td><%=jdrs.getString("place") %></td>

        <td><%=jdrs.getString("time") %></td>

        <td><%=jdrs.getString("people") %></td>                   

      </tr>

      <%

        }        

        }

      %>

</table>

    </div>

<div id="tabContent3"  class="tc"  style="display: none">

  <form action="MainServlet?method=dsAdd" method="post"  name="diushi" >

   <table>

    <tr height="25">

      <td colspan="2" align="center" bgcolor="lightgrey">

      请填写下列信息:

      </td>

    </tr>

    <tr>

     <td align="right">描述(必填内容):</td>

     <td><input type="text" name="name" size="27"></td>

    </tr>

    <tr>

     <td align="right">地点:</td>

     <td><input type="text" name="place" size="27"></td>

    </tr>

    

    <tr>

     <td align="right">丢失时间段(必填内容):</td>

     <td>

     <input type="datetime-local" name="time1" id="time1">

     <input type="datetime-local" name="time2" id="time2">

</td>

    </tr>

    <tr>

     <td align="right">本人联系方式(必填内容):</td>

     <td><input type="text" name="people" size="27"></td>

    </tr>

<!--     <tr>

     <td align="right">具体描述:</td>

     <td><textarea name="info" cols="60" rows="7"></textarea></td>

    </tr> -->

    <tr>

     <td colspan="2" align="center">

       <input type="submit" name="submit" value="提交" onclick="return checkds()">

       <input type="reset" name="reset" value="重置">       

     </td>

    </tr>

   </table>

  </form>

    </div>

<div id="tabContent4"  class="tc"  style="display: none">

  <form action="dojiandao.jsp" name="jiandao">

   <table>

    <tr height="25">

      <td colspan="2" align="center" bgcolor="lightgrey">

      请填写下列信息:

      </td>

    </tr>

    <tr>

     <td align="right">描述(必填内容):</td>

     <td><input type="text" name="name" size="27"></td>

    </tr>

    <tr>

     <td align="right">地点(可不填):</td>

     <td><input type="text" name="place" size="27"></td>

    </tr>

    <tr>

     <td align="right">时间(可不填):</td>

     <td><input type="datetime-local" name="time"></td>

    </tr>

    <tr>

     <td align="right">本人联系方式(必填内容):</td>

     <td><input type="text" name="people" size="27"></td>

    </tr>

    <tr>

     <td colspan="2" align="center">

       <input type="submit" name="submit" value="提交" onclick="return checkjd()">

       <input type="reset" name="reset" value="重置">       

     </td>

    </tr>

   </table>

  </form>

    </div>

对数据库信息进行增加的代码如下所示

req.setCharacterEncoding("UTF-8");

String name = req.getParameter("name");

String place = req.getParameter("place");

String time1 = req.getParameter("time1");

String time2 = req.getParameter("time2");

String people = req.getParameter("people");

System.out.print(name);

if(dao.dsAdd(name,place,time1,time2,people)) {

req.setAttribute("message", "Form submission was successful!");

req.getRequestDispatcher("Maintest.jsp").forward(req, resp);

}else {

req.setAttribute("message", "Form submission was fail!");

req.getRequestDispatcher("Maintest.jsp").forward(req, resp);

}

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<jsp:useBean id="db" class="com.jb.db.jdDB"/>

<html>

<head>

<title>捡到表单</title>

</head>

<%

  request.setCharacterEncoding("UTF-8");

  String   mess="";

  String   name=request.getParameter("name");

  String   place=request.getParameter("place");

  String   time=request.getParameter("time");

  String   people=request.getParameter("people");

  if(place==null||place==""){

  place="未留此信息";

  }

  boolean mark=true;

  if(mark){

      String sql="insert into jd values('"+name+"','"+place+"','"+time+"','"+people+"')";

      int i=db.insert(sql);

      db.closed();

      if(i>0)

      {

       out.print("<script>alert('Form submission was successful!');window.location.href='Maintest.jsp'</script>");

       }

      else

       mess="插入失败!";

  }

%>

<body>

  <table>

   <tr bgcolor="lightgrey">

    <td>友情提示!</td>

   </tr>

   <tr>

    <td align="center"><%=mess%></td>

   </tr>

  </table>

  <a href="jiandao.jsp">[返回上一级]</a>

  <a href="xuesheng.jsp">[返回学生界面]</a>

</body>

</html>

完成任务:

完成了失物招领表单的提交和寻物启事表单的提交。

遇到的问题:按照时间段对表单继续查询。

解决方式:使用datetime文件格式对时间填写格式进行限制。方便按时间段查询功能的实现。

明天完成的任务:实现关键字查询以及模糊查询