V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
taofuan
V2EX  ›  问与答

请问,大家在 Controller 层里是直接使用类似 JSONObject 这样的对象,还是为 Controller 的参数和返回建立相应的值对象?

  •  
  •   taofuan · Oct 31, 2016 · 2216 views
    This topic created in 3478 days ago, the information mentioned may be changed or developed.
    例如:
    是这样
    xxxController
    public String xxxAction(JSONObject jsonObj) {
    ...
    }

    xxxController
    public String xxxAction(HttpServletRequest request, HttpServletResponse response) {
    String rawContent = request.getParameter("content");
    JSONObject paramContentObj = JSONObject.parseObject(rawContent);
    }


    还是这样?
    xxxController
    public String xxxAction(xxxVO valObj) {
    ...
    }
    3 replies    2016-10-31 12:45:26 +08:00
    Ouyangan
        1
    Ouyangan  
       Oct 31, 2016   ❤️ 1
    java? springmvc 直接 @ResponseBody
    taofuan
        2
    taofuan  
    OP
       Oct 31, 2016
    @Ouyangan 就是说也要建立相应的值对象?
    CFO
        3
    CFO  
       Oct 31, 2016 via Android
    @Ouyangan 不应该是 @Requestbody 吗?看情况楼主问的是请求体
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1285 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 23:55 · PVG 07:55 · LAX 16:55 · JFK 19:55
    ♥ Do have faith in what you're doing.