package com.hao.controller;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.hao.service.StudentService;
@Controller
public class StudentController {
@Autowired
private StudentService studentService;
@RequestMapping("list")
public ModelAndView list() {
ModelAndView mv = new ModelAndView();
List<Map<String , Object>> studentList = studentService.findStudentList();
mv.addObject("studentList", studentList);
mv.setViewName("list");
return mv;
}
@RequestMapping("toAdd")
public ModelAndView toAdd() {
ModelAndView mv = new ModelAndView();
mv.setViewName("add");
return mv;
}
@RequestMapping("add")
public String add() {
studentService.add();
return "redirect:list";
}
@RequestMapping("delete")
public String delete(Integer id) {
studentService.delete(id);
return "redirect:list";
}
@RequestMapping("toUpd")
public ModelAndView toUpd(Integer id) {
ModelAndView mv = new ModelAndView();
Map<String, String> stuMap = studentService.getStudent(id);
mv.addObject("stuMap", stuMap);
mv.setViewName("update");
return mv;
}
}
自认怀才不遇怨天尤人的人多半不适合当朋友,因为你不知道他什么时候就在抱怨老天的时候把他的失败抱怨在你身上
——江南
388

被折叠的 条评论
为什么被折叠?



