直接上代码吧
package com.zhongruan.controller;
import com.zhongruan.bean.User;
import com.zhongruan.service.Iuserservice;
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 java.util.List;
@Controller
public class Dl {
@Autowired
private Iuserservice service;
@RequestMapping(“findall.do”)
public ModelAndView findall(){
ModelAndView modelAndView=new ModelAndView();
List finda =service.finda();
modelAndView.setViewName(“Cg.jsp”);
modelAndView.addObject(“hhh”,finda);
return modelAndView;
}
@RequestMapping("denl.do")
public String denl(User user){
// ModelAndView modelAndView=new ModelAndView();
// String us = req.getParameter(“username”);
// String pa=req.getParameter(“password”);
System.out.println(user);
Boolean pp=service.pd(user.getUsername(),user.getPassword());
if (pp){
return “redirect:/findall.do”;
}else{
return “Sb.jsp”;
}
}
@RequestMapping("delect.do")
public String delect(int id){
service.shanchu(id);
return "redirect:/findall.do";
}
@RequestMapping("modify.do")
public String modify(User user){
service.xg(user);
return "redirect:/findall.do";
}
@RequestMapping("modify2")
public ModelAndView modify2(User user){
ModelAndView modelAndView=new ModelAndView();
modelAndView.addObject("pp",user);
modelAndView.setViewName("Xiugai.jsp");
return modelAndView;
}
@RequestMapping("add.do")
public String add(User user){
service.xz(user);
return "redirect:/findall.do";
}
}