首先说一下基本的区别和概念 最后举例说明

一.RequestMapping和GetMapping的区别

RequestMapping和GetMapping都是用来定义请求路径的注解,区别就是GetMapping是RequestMapping的简些形式
@GetMapping是一个组合注解,是@RequestMapping(method = RequestMethod.GET)的缩写
例如:

    @GetMapping("hello") ==> @RequestMapping(value="hello",method=RequestMethod.GET)

二.RestController和Controller的区别

@RestController是@Controller和@ResponseBody的缩写形式
一个controller中返回的数据分为两种情况
1.返回页面例如jsp html等页面,只能使用@controller注解配合视图解析器返回,不能使用@RestController,也就是说 
  上面千万不能加@ResponseBody注解
2.直接返回数据例如json,xml String等其他自定义的格式,使用@Controller但是必须加上@ResponseBody注解 也就是 
  @RestController注解

RestController和Controller的区别举例说明

  1).使用返回页面例如jsp html等
@Controller
@RequestMapping("user") 或者:@RequestMapping(value="user",method=RquestMethod.GET)
public class UserController{
    @RequestMapping("toUsers")
    public String toUsers(){
      return "users" 
 }
}
请求路径是 localhost:8080/user/toUsers 然后跳转到users.jsp页面上。
 2).如果直接返回json或者xml等其他格式的数据
@RestController 也就是 /*@Controller + @ResponseBody*/
public class helloController {
    @GetMapping("hello")
    public String hello(){
        return "hello  Springboot!";
    }
}
访问 localhost:8080/hello 然后在页面中显示hello Springboot!