首页>代码>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";
}
}
最近下载更多
Rubiai LV1
2024年12月26日
Administration620 LV1
2024年12月9日
111rose LV1
2024年11月22日
star33xxz LV1
2024年6月28日
2032867896 LV1
2024年6月20日
hongdongdong LV14
2024年6月18日
卢旯旯 LV4
2024年6月10日
yqlllll LV2
2024年6月4日
minjiang110 LV3
2024年1月3日
wwwww816 LV5
2023年12月19日
最近浏览更多
wwwwwww453 LV3
12月24日
1271247100 LV9
11月22日
奋斗的小蚂蚁 LV17
10月28日
甜心冰淇淋 LV4
6月15日
shhhhhh
6月13日
暂无贡献等级
llxxyy
6月9日
暂无贡献等级
段池卿 LV5
5月23日
tomsrt
4月22日
暂无贡献等级
xiaoaitx LV8
1月1日
ma406805131 LV19
2024年12月26日

