@Controller
スプリングとアノテーションの違い@RestController
。
@Controller
アノテーションは Web MVC アプリケーションと REST アプリケーションの両方に使用できますか?
使用できる場合、Web MVC アプリケーションか REST アプリケーションかをどのように区別できますか。
ベストアンサー1
@Controller
クラスを Spring MVC コントローラーとしてマークするために使用されます。@RestController
@Controller
は、および注釈を追加するだけの便利な注釈です@ResponseBody
(参照:Javadoc)
したがって、次の2つのコントローラ定義は同じことを行う必要があります
@Controller
@ResponseBody
public class MyController { }
@RestController
public class MyRestController { }