2.21 Javaweb 总结
今日实现功能,页面的改进
package service;
import bean.Dbean;
import dao.Dao;
import java.sql.SQLException;
import java.util.List;
public class Service {
    Dao tDao=new Dao();
    public boolean add(Dbean ten) throws SQLException, ClassNotFoundException {
        boolean f = false;
        if(!tDao.name(ten.getDate()))
        {
            tDao.add(ten);
            f=true;
        }
        return f;
    }
    public boolean del(String title) throws SQLException, ClassNotFoundException {
        tDao.delete(title);
        return true;
    }
    public Dbean getbytitle(String title) throws SQLException, ClassNotFoundException {
        return tDao.getbytitle(title);
    }
    public List<Dbean> list() throws SQLException, ClassNotFoundException {
        return tDao.list();
    }
}
<html>
<head>
  <title>每日在线打卡</title>
</head>
<body>
<form method="post"  action="AddServlet">
  <table align="center" border="1" width="600">
    <tr>
      <td>日期</td>
      <td>
        <input type="text" name="date" ><br>
      </td>
    </tr>
    <tr>
      <td>每日关键字</td>
      <td>
        <input type="text" name="zi" ><br>
      </td>
    </tr>
    <tr>
      <td>每日总结</td>
      <td>
        <input type="text" name="zong" ><br>
      </td>
    </tr>
    <tr>
      <td>坚持天数</td>
      <td>
        <input type="text" name="days" ><br>
      </td>
    </tr>
    <tr>
      <td>连续最长天数</td>
      <td>
        <input type="text" name="Mdays" ><br>
      </td>
    </tr>
    <tr align="center">
      <td colspan="2">
        <button>提交</button>
      </td>
    </tr>
  </table>
</form>
</body>
</html>
<html>
<head>
    <title>浏览</title>
</head>
<body>
<h2 align="center" >操作成功</h2><br>
<table align="center"  border="1">
    <tr>
        <td align="center" width=10%>日期</td>
        <td align="center" width=10%>每日关键字</td>
        <td align="center" width=10%>每日总结</td>
        <td align="center" width=10%>坚持天数</td>
        <td align="center" width=10%>连续最长天数</td>
    </tr>
    <%
        Connection connection= DBUtil.getConnection();
        PreparedStatement preparedStatement=null;
        ResultSet in=null;
        try{
//        按照添加时间排序::
            preparedStatement=connection.prepareStatement("select * from daka");
            in = preparedStatement.executeQuery();
            while(in.next()){
    %>
    <tr>
        <td><%=in.getString(1)%></td>
        <td><%=in.getString(2)%></td>
        <td><%=in.getString(3)%></td>
        <td><%=in.getString(4)%></td>
        <td><%=in.getString(5)%></td>
    </tr>
    <%
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            connection.close();
            preparedStatement.close();
            in.close();
        }
    %>
    <p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
        <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
</table>
</body>
</html>
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号