首页>代码>spring boot+mybatis+thymeleaf开发实现基于内嵌式数据库H2的增删该查入门简单实例>/yourProject/src/main/java/com/example/demo/controller/StudentController.java
package com.example.demo.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.example.demo.entity.Student;
import com.example.demo.enums.GenderTypeEnum;
import com.example.demo.service.StudentService;

@Controller
@RequestMapping("/stu")
public class StudentController {

	@Resource
	private StudentService studentService;
	
	@RequestMapping("/add")
	public String addStudent(@ModelAttribute(value="student") Student student) {
		studentService.addStudent(student);		
		return "redirect:/";
	}
	
	@RequestMapping("/update")
	public String updateStudent(@ModelAttribute(value="student") Student student) {
		studentService.updateStudent(student);		
		return "redirect:/";
	}
	
	@RequestMapping("/delete")
	public String deleteStudent(HttpServletRequest request) {
		int id = Integer.valueOf(request.getParameter("id"));
		studentService.deleteStudent(id);
		return "redirect:/";
	}
	
	
}
最近下载更多
anopsign  LV1 2022年6月30日
caozongan  LV19 2022年1月10日
swordking  LV1 2021年6月22日
1690356080  LV37 2021年6月15日
yongjava21  LV26 2021年2月19日
阿风啦  LV14 2021年1月24日
时代信念  LV4 2020年12月24日
hjd3983  LV10 2020年11月22日
vaterz  LV25 2020年11月18日
2223915172  LV4 2020年10月19日
最近浏览更多
夜起星河  LV8 2023年12月27日
zhaozhiqi  LV5 2023年10月19日
小妹妹  LV7 2023年9月20日
ewan007  LV29 2023年7月7日
renjunyou  LV10 2023年3月6日
13112360  LV2 2023年2月8日
961218169 2023年1月25日
暂无贡献等级
ChenZheMeng  LV3 2022年12月21日
easyzzh  LV3 2022年10月8日
win1991  LV6 2022年8月18日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友