首页>代码>spring+spring mvc+mybatis+jsp实现简单学生信息管理系统>/StudentDemo/src/com/ms/ssm/controller/StudentController.java
                
                package com.ms.ssm.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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 org.springframework.web.servlet.ModelAndView;
import com.ms.ssm.pojo.Student;
import com.ms.ssm.service.StudentService;
import com.sun.org.apache.regexp.internal.recompile;
@Controller
public class StudentController {
	@Autowired
	StudentService studentService;
	
	//查询全部信息
	@RequestMapping("selectAllStu")
	public ModelAndView selectAllStudent(Student student){
		
		List<Student> list=studentService.selectAllStudent();
		
		ModelAndView modelAndView=new ModelAndView();
		
		modelAndView.addObject("list", list);
		modelAndView.setViewName("selectAllStu");
		return modelAndView;
	}
	
	//返回查询页面
	@RequestMapping("selectView")
	public String selectView(){
		return "selectView";
	}
	//返回查询结果页面
	@RequestMapping("selectStu")
	public String selectStu(HttpServletRequest request,HttpServletResponse response,Model model){
		
		String name=request.getParameter("name");
		//把string类型的转换成Integer类型的
		    
		     List<Student> list=studentService.selectStu(name);
		     		if(list.isEmpty()){
		     			return "fail";
		     		}else{
		     			model.addAttribute("list", list);
						return "selectStuResult";
		     		}
	}
	
	//删除信息
	@RequestMapping("deleteStu")
	public String deleteStu(Model model,
			@RequestParam(value = "id", required = true) Integer id){
		
		studentService.deleteStu(id);
		
		return "success";
	}
	
	//返回添加学生页面
	@RequestMapping("insertView")
	public String getInsertView(){
		return "insertStu";
	}
	//执行添加操作
	@RequestMapping("insertStu")
	public String insertStu(Student student,
			HttpServletRequest request,HttpServletResponse response){
					studentService.insertStu(student);
					return "success";
	}
	
	//返回修改学生页面
	@RequestMapping("updateStu")
	public String getUpdateView(Model model,
			@RequestParam(value = "id", required = true) Integer id){
		Student student=studentService.selectUpdateStu(id);
		model.addAttribute("student", student);
		return "updateStuView";
	}
	//执行修改操作
	@RequestMapping("doUpdateStu")
	public String doupdateStu(Student student){
		studentService.updateStu(student);
		return "success";
	}
}
最近下载更多
                
                甜心冰淇淋     LV4
                6月21日
            
            
        
                xiaoaitx     LV8
                2024年11月22日
            
            
        
                hongdongdong     LV14
                2024年6月18日
            
            
        
                xiaolu-123     LV1
                2024年4月9日
            
            
        
                wwwww816     LV5
                2023年12月19日
            
            
        
                李亮     LV19
                2023年8月29日
            
            
        
                磊少不在     LV2
                2023年6月18日
            
            
        
                tmf852     LV5
                2023年6月18日
            
            
        
                2819271872     LV1
                2023年6月16日
            
            
        
                1257592068     LV6
                2023年6月13日
            
            
        
    
                
                
最近浏览