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日
最近浏览更多
tomsrt 4月22日
暂无贡献等级
xiaoaitx  LV8 1月1日
ma406805131  LV19 2024年12月26日
xiuele 2024年12月26日
暂无贡献等级
Rubiai  LV1 2024年12月26日
Administration620  LV1 2024年12月9日
2194192290li  LV1 2024年12月3日
111rose  LV1 2024年11月21日
LZPCJM  LV1 2024年11月19日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友