首页>代码>easyUI+SSM整合实现增删改查及分页实例>/easyui_day1102_1/src/main/java/com/ssm/example/controller/StudentController.java
package com.ssm.example.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ssm.example.entity.Student;
import com.ssm.example.service.StudentService;

@Controller
public class StudentController {

	@Autowired
	private StudentService studentService;

	/**
	 * 查找所有学生
	 * 
	 * @return
	 */
	@RequestMapping(value = "/list")
	@ResponseBody
	public Map<String,Object> list(HttpServletRequest request) {
		String names = request.getParameter("names");
		System.out.println(names);
		int page = Integer.parseInt(request.getParameter("page"));
		int pageSize = Integer.parseInt(request.getParameter("rows"));
		int startRows = pageSize*(page-1);
		List<Student> list = studentService.findAll(names,startRows,pageSize);
		int count = studentService.getRowCount();
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("total", count);
		map.put("rows", list);
		return map;
	}

	@RequestMapping(value = "/add")
	@ResponseBody
	public int add(Student student) {
		return studentService.addStudent(student);
	}

	@RequestMapping(value = "/update")
	@ResponseBody
	public int update(Student student) {
		return studentService.updateStudentById(student);
	}

	@RequestMapping(value = "/read")
	@ResponseBody
	public Student read(Student student) {
		return studentService.selectUsersById(student);
	}

	@RequestMapping(value = "/delete")
	@ResponseBody
	public int delete(Integer id) {
		System.out.println("i came");
		return studentService.deleteStudentById(id);
	}
}
最近下载更多
张朕朕  LV3 2023年9月1日
potato1234  LV6 2022年3月22日
rebecca0214  LV2 2021年5月7日
大瓜次郎  LV2 2021年3月27日
张先生1121  LV3 2021年1月11日
hxkj123456  LV6 2020年12月2日
1282954475  LV3 2020年11月10日
CSS199669  LV25 2020年7月26日
李海洋  LV12 2020年6月27日
netstat01  LV3 2020年6月22日
最近浏览更多
uni-code_0123  LV1 2023年11月27日
vitos5n  LV9 2023年9月27日
张朕朕  LV3 2023年9月1日
1748938504  LV2 2023年6月30日
 LV7 2023年3月29日
xhjzsx0715  LV1 2023年3月11日
milou123  LV2 2023年3月7日
cammysu  LV1 2023年1月31日
h_z_feng  LV1 2022年12月24日
qwer123978ca  LV1 2022年12月20日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友