首页>代码>SSM(spring+spring MVC+mybatis)开发学生信息后台管理系统,实现学生增删改查功能>/test3/src/com/yyx/controller/StudentController.java
package com.yyx.controller; import java.util.List; import javax.servlet.http.HttpServletRequest; 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.servlet.ModelAndView; import com.yyx.po.Student; import com.yyx.service.StudentService; @Controller public class StudentController { @Autowired private StudentService studentService; public void setStudentService(StudentService studentService) { this.studentService = studentService; } // 根据id查询学生信息 @RequestMapping("/findStudentById") public String findStudentById(Integer id,Model model){ Student student = studentService.findStudentById(id); model.addAttribute("student", student); return "student"; } //删除信息 @RequestMapping("/deleteStudentById") /* public String deleteStudentById(Integer id,Model model){ studentService.deleteStudentById(id); return "success"; }*/ public String deleteStudentById(Integer id,Model model){ int row=studentService.deleteStudentById(id); if (row>0) return "success"; else return "fail"; } //修改信息 @RequestMapping("/updateStudentById") public String updateStudentById(Student student,Model model){ studentService.updateStudentById(student); return "success"; } @RequestMapping("/addStudent") public String addStudentById(Student student,Model model){ studentService.addStudent(student); return "success"; } @RequestMapping("/findall") public ModelAndView stuList(){ ModelAndView modelAndView=new ModelAndView(); List<Student> list; list=studentService.findall(); modelAndView.addObject("students",list); modelAndView.setViewName("studentindex"); return modelAndView; } @RequestMapping("/addstudentindex") public String addstudentindex(){ return "addstudent"; } @RequestMapping("/updatestudent") public String updateStudent(Integer id,Model model){ Student student = studentService.findStudentById(id); model.addAttribute("student", student); return "updatestudent"; } }
最近下载更多
minjiang110 LV3
1月3日
wwwww816 LV3
2023年12月19日
sunshine9920 LV12
2023年11月7日
李亮 LV19
2023年8月28日
gecongkai LV8
2023年6月22日
hedyyy LV3
2023年6月16日
短巷拥猫 LV11
2023年6月15日
微信网友_6505997864357888 LV3
2023年6月5日
bismarcktirppitz LV2
2023年6月4日
hxjhxjlhw LV1
2023年5月30日
最近浏览更多
幸福一家人
4月23日
暂无贡献等级
alphaeix
3月18日
暂无贡献等级
1437047954
3月7日
暂无贡献等级
minjing123 LV8
1月4日
minjiang110 LV3
1月3日
Nuyoah_L
1月3日
暂无贡献等级
zzzzzzz09173
2023年12月27日
暂无贡献等级
潘潘123456 LV2
2023年12月24日
LiBaQi LV2
2023年12月22日
磊哥哥哥哥 LV13
2023年12月22日