发表于: 2018-05-19 21:56:37

1 1074


今天完成的事情:(一定要写非常细致的内容,比如说学会了盒子模型,了解了Margin) 

今天完成了增删功能

package com.task2.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.task2.pojo.Student;
import com.task2.service.StuService;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class FormController {
@Resource
   private StuService stuService;
   @RequestMapping(value = "/form", method = RequestMethod.GET)
public String form(Model model){
List<Student> studentList= stuService.selectAll();
       model.addAttribute("Students", studentList);
       return "form";
   }
@RequestMapping(value = "/register", method = RequestMethod.GET)
public String toRegister() {
return "register";
   }

@RequestMapping(value = "/register", method = RequestMethod.POST)
public String register(Student student) {
stuService.insert(student);
       return "redirect:/form";
   }

@RequestMapping(value = "/delete", method = RequestMethod.GET)

public  String delete(Integer s_id) {
stuService.delete(s_id);
       return "redirect:/form";
   }

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
   <title>表格</title>
</head>
<body>

<table cellpadding="0" cellspacing="0" border="1"
style=" border-collapse: collapse;min-height: 300px;width: 1800px;text-align: center;">
   <tr>
       <td colspan="14" align="left">
           <a href="register">添加</a>
       </td>
   </tr>
   <tr>
       <td colspan="14" align="left">
       <form action="/find"method="get">
学号: <input name="s_id" >
       <input type="submit" value="查询"/>
       </form>
       </td>
   </tr>
   <tr>
       <td>学号</td>
       <td>姓名</td>
       <td>QQ</td>
       <td>入学时间</td>
       <td>类型</td>
       <td>学校</td>
       <td>日报链接</td>
       <td>立愿</td>
       <td>师兄</td>
       <td>从哪知道</td>
       <td>创建时间</td>
       <td>更新时间</td>
       <td>修改</td>
       <td>删除</td>
   </tr>
<c:forEach items="${Students}" var="li" varStatus="i">
<tr>
       <td>${li.s_id}</td>
       <td>${li.s_name}</td>
       <td>${li.s_qq}</td>
       <td>${li.s_time}</td>
       <td>${li.s_type}</td>
       <td>${li.s_school}</td>
       <td>${li.s_link}</td>
       <td>${li.s_words}</td>
       <td>${li.s_brother}</td>
       <td>${li.s_know}</td>
       <td>${li.create_at}</td>
       <td>${li.update_at}</td>
       <td><a type="button"  href="${path}update?id=${li.s_id}" class="btn btn-info btn-sm">
           <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
修改</a>
       </td>
       <td> <a type="button"  href="${path}/delete?s_id=${li.s_id}" class="btn btn-danger btn-sm">
           <span class="glyphicon glyphicon-trash" aria-hidden="true" ></span>
删除</a>
       </td>
   </tr>
</c:forEach>

重建了一下表格

前面问题有点多,效率有点低

明天计划的事情:写完查改功能吧。
遇到的问题:增和删的实现,百度和问师兄
收获:不懂得还是多,写代码要规范和细致。


返回列表 返回列表
评论

    分享到