zoukankan      html  css  js  c++  java
  • 通用结果类 Result

    package com.zhongyuan.ota.utils;
    
    import java.util.HashMap;
    import java.util.Map;
    
    /**
     * 返回结果数据
     */
    public class Result extends HashMap<String, Object> {
    
        private static final long serialVersionUID = 1L;
    
        public Result() {
            put("code", 0);
        }
    
        public static Result error() {
            return error(500, "未知异常,请联系管理员");
        }
    
        public static Result error(String msg) {
            return error(500, msg);
        }
    
        public static Result error(int code, String msg) {
            Result result = new Result();
            result.put("code", code);
            result.put("msg", msg);
            return result;
        }
    
        public static Result success() {
            return new Result();
        }
        
        public static Result success(String msg) {
            Result result = new Result();
            result.put("msg", msg);
            return result;
        }
        
        public static Result success(String msg, int total, Object object) {
            Result result = new Result();
            result.put("msg", msg);
            result.put("total", total);
            result.put("rows", object);
            return result;
        }
    
        public static Result success(Map<String, Object> map) {
            Result result = new Result();
            result.putAll(map);
            return result;
        }
    
        @Override
        public Result put(String key, Object value) {
            super.put(key, value);
            return this;
        }
    }
  • 相关阅读:
    JSTL XML标签库 使用
    JSTL SQL标签库 使用
    JSTL I18N 格式标签库
    基于struts2的ajaxfileupload异步上传插件的使用
    Spring 使用注解方式进行事务管理
    vi编辑器的使用方式
    js基础知识介绍
    选择语句
    数组
    0411作业
  • 原文地址:https://www.cnblogs.com/zygyun/p/8674650.html
Copyright © 2011-2022 走看看