2016-03-10 58 views
0

我正在使用Spring Boot,並嘗試顯示獲取請求。我使用的是2類:Greeting.javaGreetingController導航器訪問RequestMapping canot

package greeting; 

public class Greeting { 

    private final long id; 
    private final String content; 

    public Greeting(long id, String content) { 
     this.id = id; 
     this.content = content; 
    } 

    public long getId() { 
     return id; 
    } 

    public String getContent() { 
     return content; 
    } 
} 

我控制器GreetingController.java:

public class GreetingController { 

    private static final String template = "Hello ,%s!"; 
    private final AtomicLong counter = new AtomicLong(); 

    @RequestMapping(value="/greeting",method = RequestMethod.GET) 
    public Greeting greeting(@RequestParam(value = "name",defaultValue = "World")String name){ 
     return new Greeting(counter.incrementAndGet(),String.format(template,name)); 
    } 
} 

當我插入這個URL(http://localhost:8080/greeting?name=gabriel)我上導航此錯誤:

Whitelabel Error Page 

This application has no explicit mapping for /error, so you are seeing this as a fallback. 

Thu Mar 10 19:35:17 CET 2016 
There was an unexpected error (type=Not Found, status=404). 
No message available 

我不明白他爲什麼沒找到頁面。 如果一個人可以幫我:)

謝謝

回答

1

/greeting存在的映射,但出現錯誤導致一個重定向到尚未配置

+0

非常感謝你的位置/error zaafrani