发表于: 2017-07-29 21:43:44

2 841


今日完成的事:

<%--
 Created by IntelliJ IDEA.
 User: feyesesbvs
 Date: 2017/7/30
 Time: 3:48
 To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>My JSP 'stdslist.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<script type="text/javascript" src="/webapp/static/bootstrap-3.3.7-dist/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
function deletestds(id) {

{
var str = window.confirm("are you sure ?");

if(str){
location.href="delete?id="+id;
}
}
</script>
</head>

</head>
<body>
<div align="center">
<input type="button" value="新增" onclick="location.href='toAdd'">
</div>
<table width="80%" border="1" cellpadding="2" cellspacing="0" align="center">
<tr>
<th>id</th>
<th>updata_at</th>
<th>create_at</th>
<th>name</th>
<th>qq</th>
<th>jobs</th>
<th>join_time</th>
<th>school</th>
<th>online_id</th>
<th>data_url</th>
<th>declaration</th>
<th>teacher</th>
<th>sources</th>
</tr>
<c:forEach items="${stds}" var="stds">
<tr>
<th>${stds.Student}</th>
<th>${stds.updata_at}</th>
<th>${stds.create_at}</th>
<th>${stds.name}</th>
<th>${stds.qq}</th>
<th>${stds.jobs}</th>
<th>${stds.join_time}</th>
<th>${stds.school}</th>
<th>${stds.online_id}</th>
<th>${stds.data_url}</th>
<th>${stds.declaration}</th>
<th>${stds.teacher}</th>
<th>${stds.sources}</th>
<td>
<input type="button" value="修改" onclick="location.href='toUpdate?id=${stds.id}'" />
<input type="button" value="删除" onclick="delete_stds(${stds.id});" />
</td>
</tr>
</c:forEach>
</table>
</body>
</html>


package com.jnshu.controller;


import com.jnshu.dao.StudentDao;
import com.jnshu.pojo.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

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

/**
* Created by feyesesbvs on 2017/7/30.
*/
@Controller
public class StudentController {
@Resource
   private StudentDao studentDao;

public StudentController setStudentDao(StudentDao studentDao){
this.studentDao = studentDao;
return this;
}
//查询全部
   @RequestMapping("/find")
public String find(Model model){
List<Student> list = studentDao.findAll();
model.addAttribute( "stds",list );
return "stdslist";
}

//打开新增页面
   @RequestMapping("/toAdd")
public String toAdd(){
return "addStds";
}

//新增保存
 @RequestMapping("/add")
public String add(Student student){
studentDao.save( student );
return "redirect:find";
}


//打开修改页面
@RequestMapping("/toUpdate")
public String toUpdate(@RequestParam("id")long id,Model model){
Student student =studentDao.findById( id );
model.addAttribute( "stds",student );
return "updatestds";
}
//修改保存
   @RequestMapping("/update")
public String update(Student student){
studentDao.update(student);
return "redirect:find";
}
//删除
   @RequestMapping("/delete")
public String delete(@RequestParam("id") long id){
studentDao.delete(id);
return "redirect:find";
}

}


饿,我的jsp也面和controller层存在很大的问题啊。找了个例子抄了下来结果,发现标签没用好,各种乱找不到注入点。


明天的计划:学习一下jap

遇到的问题:一样

收获: 终于知道哪里找切入问题


返回列表 返回列表
评论

    分享到