NutzCN Logo
问答 nutzwk中,Result在前台无法返回msg
发布于 11天前 作者 qq_d6d46f6d 62 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

页面中无法获取到msg,简单写了个测试方法,
msg参数有传入


@At("/test") @Ok("json:full") public Object test(HttpServletRequest req) { return new Result(0,"test",new String("ceshi")); }

但下面这里获取的msg是空的、data是可以返回的,请问如何调整?

    this.msg = Mvcs.getMessage(Mvcs.getActionContext().getRequest(), msg);
6 回复

有使用中,Result.success("ok")

this.msg是哪来的东西

result类的构造方法

package com.timemans.common.base;

import org.nutz.mvc.Mvcs;

/**
 * Created by wizzer on 2016/6/22.
 */
public class Result {

    private int code;
    private String msg;
    private Object data;

    public Result() {
    }

    public Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = Mvcs.getMessage(Mvcs.getActionContext().getRequest(), msg);
        this.data = data;
    }

    public static Result success(String content) {
        return new Result(0, content, null);
    }

    public static Result success(String content, Object data) {
        return new Result(0, content, data);
    }

    public static Result error(int code, String content) {
        return new Result(code, content, null);
    }

    public static Result error(String content) {
        return new Result(1, content, null);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}

msg文件里面没加对应的键值

添加回复
请先登陆
回到顶部