package com.mvc.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.mvc.entity.Student;
import com.mvc.service.StudentService;
@Controller
@RequestMapping("/student.do")
public class StudentController {
protected final transient Log log = LogFactory
.getLog(StudentController.class);
@Autowired
private StudentService studentService;
public StudentController(){
}
@RequestMapping
public String load(ModelMap modelMap){
List<Object> list = studentService.getStudentList();
modelMap.put("list", list);
return "student";
}
@RequestMapping(params = "method=add")
public String add(HttpServletRequest request, ModelMap modelMap) throws Exception{
return "student_add";
}
@RequestMapping(params = "method=save")
public String save(HttpServletRequest request, ModelMap modelMap){
String user = request.getParameter("user");
String psw = request.getParameter("psw");
Student st = new Student();
st.setUser(user);
st.setPsw(psw);
try{
studentService.save(st);
modelMap.put("addstate", "添加成功");
}
catch(Exception e){
log.error(e.getMessage());
modelMap.put("addstate", "添加失败");
}
return "student_add";
}
@RequestMapping(params = "method=del")
public void del(@RequestParam("id") String id, HttpServletResponse response){
try{
Student st = new Student();
st.setId(Integer.valueOf(id));
studentService.delete(st);
response.getWriter().print("{\"del\":\"true\"}");
}
catch(Exception e){
log.error(e.getMessage());
e.printStackTrace();
}
}
}
Andy_20150913
- 粉丝: 2
- 资源: 11
最新资源
- 国际象棋检测7-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord数据集合集.rar
- 【一文搞懂:什么是集成学习-原理+python代码】
- 德普微一级代理 DP3145D SOT23-6 USB PD 协议单口控制器
- java毕设项目之学习视频资源库的系统+jsp(完整前后端+说明文档+mysql).zip
- 基于java实现的快速排序代码
- java毕设项目之游泳会员管理系统+vue(完整前后端+说明文档+mysql+lw).zip
- 巨潮资讯网5000只股票orgId-dict加密字典
- java毕设项目之中文学习系统的设计与实现+jsp(完整前后端+说明文档+mysql+lw).zip
- 德普微一级代理 DP021N03FGLI DFN5*6 DPMOS N-MOSFET 30V 180A 1.8mΩ
- java毕设项目之zy+养老服务平台设计+vue(完整前后端+说明文档+mysql+lw).zip
- 【java毕业设计】SpringBoot+Vue幼儿园管理系统 源码+sql脚本+论文 完整版
- 德普微一级代理 DP100N06MGL PDFN3.3*3.3 TRMOS N-MOSFET 60V, 8mΩ, 45A
- mongoose-free-6.9
- dnSpy-net-win32-222.zip
- 国际象棋检测8-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma数据集合集.rar
- cvtocc-shanghai.hbm
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈