发表于: 2018-02-28 23:38:59
1 818
今天完成的事情
1.完成DELETE功能的实现
把DELETE变成GET
@Controller
public class StudentSController {
@Autowired
StudentSService studentSService;
@RequestMapping(value="/studentS",method= RequestMethod.GET)
public ModelAndView listStudentS(){
System.out.println("1111111111111111");
ModelAndView mav = new ModelAndView();
List<StudentS> cs=studentSService.list();
// 放入转发参数
mav.addObject("cs", cs);
// 放入jsp路径
mav.setViewName("listStudentS");
return mav;
}
@RequestMapping(value="/studentS",method=RequestMethod.PUT)
public ModelAndView addStudentS(StudentS studentS){
studentSService.add(studentS);
ModelAndView mav=new ModelAndView("redirect:/studentS");
return mav;
}
@RequestMapping(value="/StudentS/{id}",method=RequestMethod.GET)
public ModelAndView deleteStudentS(StudentS studentS){
studentSService.delete(studentS);
ModelAndView mav = new ModelAndView("redirect:/studentS");
return mav;
}
@RequestMapping(value="/studentS/{id}",method=RequestMethod.POST)
public ModelAndView updateStudentS(StudentS studentS){
studentSService.update(studentS);
ModelAndView mav = new ModelAndView("redirect:/studentS");
return mav;
}
@RequestMapping(value="/studentS/{id}",method = RequestMethod.GET)
public ModelAndView editStudentS(StudentS studentS) {
StudentS c = studentSService.get(studentS.getId());
if (null == c) {
ModelAndView mav = new ModelAndView("good");
mav.addObject("message", "用户不存在");
return mav;
}
ModelAndView mav = new ModelAndView("editStudentS");
mav.addObject("c",c);
return mav;
}
这里也改成对应的GET
<tr>
<td>id</td>
<td>name</td>
<td>age</td>
<td>编辑</td>
<td>删除</td>
</tr>
<c:forEach items="${cs}" var="c" varStatus="st">
<tr>
<td>${c.id}</td>
<td>${c.name}</td>
<td>${c.age}</td>
<td><a href="studentS/${c.id}">编辑</a></td>
<td><a class="GET" href="StudentS/${c.id}">删除</a></td>
</tr>
运行
点击删除7
成功
2,学习了一下JSP的知识,就不往上复制了
明天计划的事情
学习josn
遇到的问题
无
收获
实现了删除功能
评论