[英]Does the return keyword in a superclass method return to the subclass that called the superclass method?
[英]Why does a subclass of AbstractMvcEndpoint return a 404 despite the method being called?
在我的終結點方法中放置一個斷點,我看到它被調用並且它返回而沒有任何錯誤。 但是當它到達瀏覽器時,它說這是404錯誤。
@Configuration
@ManagementContextConfiguration
@CacheController
public class TestController extends AbstractMvcEndpoint
{
public TestController()
{
super( "/testendpoint", false, true );
}
@GetMapping( value = "/testendpoint", produces = MediaType.APPLICATION_JSON_UTF8_VALUE )
public String getSomething(HttpServletRequest request) throws Exception
{
return "hello";
}
}
是什么原因造成的?
在方法getSomething(...)
中return "hello";
因此,它將返回普通視圖( Web頁面視圖 )。
因為要返回JSON對象,所以下面方法的結果
@GetMapping( value = "/testendpoint", produces = MediaType.APPLICATION_JSON_UTF8_VALUE )
public String getSomething(HttpServletRequest request) throws Exception
{
return "hello";
}
應該是JSON對象 。
為了測試REST端點,應該使用命令curl
(在Linux上)。 如果使用Web瀏覽器,則可以使用JSON標記插件(例如: JSONView )。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.