首页>代码>基于SSM开发的网上订餐系统,包括前台页面和后台管理系统>/sourcecode/src/main/java/com/byh/biyesheji/controller/CategoryController.java
package com.byh.biyesheji.controller; import com.byh.biyesheji.pojo.Category; import com.byh.biyesheji.service.CategoryService; import org.springframework.beans.factory.annotation.Autowired; 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 java.util.List; /** * 商品分类模块controller */ @Controller @RequestMapping("/category") public class CategoryController { @Autowired private CategoryService categoryService; @RequestMapping("/list") public String list(Model model){ List<Category> list = categoryService.list(); model.addAttribute("list",list); model.addAttribute("size",list.size()); return "productmodule/category-list"; } @RequestMapping("/addCategory") public String add(@RequestParam(value = "name")String name){ Category category = new Category(); category.setName(name); categoryService.save(category); return "productmodule/category-list"; } @RequestMapping("/delCategory") public String del(@RequestParam(value = "id")int id){ categoryService.del(id); return "redirect:list"; } @RequestMapping("/editCategory") public String edit(@RequestParam(value = "id")int id,Model model){ Category category = categoryService.get(id); model.addAttribute("category",category); return "productmodule/category-edit"; } @RequestMapping("/updateCategory") public String update(Category category,Model model){ categoryService.update(category); return "redirect:list"; } }

微信网友_7298640909209600 LV2
2024年12月18日
120_wu LV4
2024年12月3日
charleswang LV7
2024年10月19日
柳咪华沙 LV7
2024年6月28日
rain112 LV31
2024年6月13日
qtingchh LV3
2024年5月3日
saaaaaa LV14
2024年4月16日
2131234536546 LV7
2024年3月31日
123ggf LV8
2024年3月15日
pangzhihui LV14
2024年3月5日