1. 程式人生 > >學習SpringBoot遇到的問題(1)路由返回靜態頁面,卻返回了靜態檔案的路徑

學習SpringBoot遇到的問題(1)路由返回靜態頁面,卻返回了靜態檔案的路徑

一、路由返回靜態頁面,卻返回了靜態檔案的路徑

解決:

1、註解使用錯誤

controller類的註解應該是 @Controller
而不是@RestController
前者只要返回RseonBody,後者可返回頁面

2、上述設定成功,卻報錯,形如:

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

Thu Oct 11 20:53:09 CST 2018
There was an unexpected error (type=Internal Server Error, status=500).
Exception parsing document: template="/up", line 6 - column 3

注意到最後一行,此時應該是HTML的語法出現了錯誤,去排除即可。可以看出我的有個地方沒有閉合標籤,話說,這規則也太嚴苛了。