我有非常簡單的春天引導創建的Hello World(只是入門網站,沒有thymeleaf等)。 我想要處理/你好URL,它應該從/static/view.html春季啓動網址.html結尾
我有我的控制器/static/view.html和簡單的方法產生的看法:
@RequestMapping("/hello")
public String hello2() {
return "hello.html";
}
的問題是,它會導致錯誤:
Circular view path [hello.html]: would dispatch back to the current handler URL [/hello.html] again
我想通了,如果我訪問/個招呼,或者/hello.html沒關係,春天對待他們一樣。
如何返回簡單,靜態的html與url路徑相同的名稱以及spring中的哪個對象mvc/boot導致像/example.html這樣的映射url只是/ example?
您的文件被命名爲view.html,但是您返回的是hello.html。爲什麼?而且,view.html不是一個視圖。這是一個公開可用的資源。你應該轉發它。 –
讓我們說,在顯示hello.html之前,我想在我的控制器中做一些邏輯(我的例子中的hello.html可以是簡單的確認頁面)。所以我想繼續做這個簡單的事情,爲什麼春季啓動地圖* .html只是*仍然有效 – swch
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle /#mvc-multiple-representations –