ssm+maven+angular+bootstrap练习--代码实现

Msg类

public class Msg {

		private int code;//状态码:100表示成功,200表示失败
		private String result;//操作成功、操作失败
		private Map data = new HashMap();
		
		
		//返回成功结果的方法
		public static Msg success(){
			Msg msg = new Msg();
			msg.setCode(100);
			msg.setResult("操作成功");
			return msg;
		}
		//返回失败结果的方法
		public static Msg fail(){
			Msg msg = new Msg();
			msg.setCode(200);
			msg.setResult("操作失败");
			return msg;
		}
		
		//存放数据,支持链式操作
		public Msg add(String key,Object value){
			this.getData().put(key, value);
			return this;		
		}
          ------------getter,setter方法省略---------

EmailMapper接口

public interface EmailMapper {
               //
	public List selectEmails(@Param("selectorder")String selectorder,@Param("sel")Integer sel);
	
	public  void update(int id);
	
	public void delete(int id);
	
	
}

EmailMapper.xml




	

	
	
	
	delete from t_email where id =#{id};
	
	
	
			update t_email set status =1 where id =#{id}
		
	
	

Controller类

@RequestMapping("email")
@Controller
public class EmailController {

	@Autowired
	private EmailServiceImpl service;
	
	@RequestMapping("selectPage")
	@ResponseBody
	public Msg selectEmpsWithJson(
			@RequestParam(value="pageno",defaultValue="1")Integer pageno
			,@RequestParam(value="pagesize",defaultValue="2")Integer pagesize
			,@RequestParam(value = "selectorder")String selectorder,@RequestParam(value = "sel",defaultValue="2")int sel){
		//指定查询的页码和每页的条数
		PageHelper.startPage(pageno, pagesize);
		//查询所有的员工数据
		List list = service.selectEmails(selectorder,sel);
		//将员工数据封装在pageInfo中
		PageInfo pageInfo = new PageInfo(list);
		return Msg.success().add("pageInfo", pageInfo);
	}
	
	@RequestMapping("delete")
	public String delete(int [] id){
		for (int i : id) {
			service.delete(i);
		}
		return "index";
	};
	
	@RequestMapping("update")
	public String  batchUpdate(int [] id){
		for (int i : id) {
			service.update(i);
		}
		return "index";
	};

	
	
}

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>



  
    
      邮箱页面
	
	
	
	
	
	
	
	
	
		
	
	
  
  





  	
  	

我的邮箱页面

id 发件人 状态 标题 时间
{{emp.id }} {{emp.name}}
{{emp.title}}
共有{{pageInfo.total}}条数据,共有{{pageInfo.pages}}页




你可能感兴趣的:(ssm+maven+angular+bootstrap练习--代码实现)