首页>代码>Spring MVC+Mybatis入门学习小项目实例>/springMVC_Mybatis_Tset/src/com/ssm/controller/BooksController.java
package com.ssm.controller; import javax.annotation.Resource; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.ssm.entity.Books; import com.ssm.service.BooksService; @Controller @RequestMapping("/books") public class BooksController { private BooksService booksService; public BooksService getBooksService() { return booksService; } @Resource public void setbooksService(BooksService booksService) { this.booksService = booksService; } /*保存数据对象 */ @RequestMapping(value="/save", method = RequestMethod.GET) public String save(Model model, Books books){ booksService.save(books); return "redirect:/books/list"; } /*列出数据对象列表 */ @RequestMapping(value="/list",method = RequestMethod.GET) public String list(Model model,Books books) { model.addAttribute("list", booksService.queryResult(books)); model.addAttribute("entity",books); return "/books_list"; } /*根据主键更新对象 */ @RequestMapping(value="/edit/{id}",method = RequestMethod.GET) public String edit(Model model,@PathVariable("id") Integer id) { model.addAttribute("entity", booksService.getBooks(id)); return "/books_edit"; } /*根据主键删除对象 */ @RequestMapping(value="/delete/{id}", method = RequestMethod.GET) public String delete(Model model, @PathVariable("id") Integer id){ booksService.delete(id); return "redirect:/books/list"; } @RequestMapping("/books_add") public String books_add(){ return "/books_add"; } @RequestMapping("/books_list") public String books_list(){ return "/books_list"; } }

李亮 LV19
2023年3月7日
YUProject LV8
2022年12月17日
haidongWang LV1
2020年10月17日
wingking LV2
2020年8月26日
凤舞水寒 LV1
2020年8月26日
Coli丶可乐 LV1
2020年5月25日
3204294009 LV1
2020年5月6日
李东曙 LV14
2020年3月27日
liuwenlong LV20
2020年1月3日
系佛山的价格 LV1
2019年12月15日