Spring MVC controller返回值类型

SpringMVC controller返回值类型:

  1 String

    return "user":将请求转发到user.jsp(forword)

    return "redirect:user":将请求重定向到user(redirect)

  2 ModelAndView

    返回数据和视图

  3 Object

    返回对象,一般用于json数据的返回

    必须在方法或方法的返回值前加@ResponseBody注解

  4 void

    返回其他的MIME类型时,通常将方法定义为void

原文地址:https://www.cnblogs.com/roxy/p/7604028.html