springboot的web項目在開發環境正常,打成jar之後模板引擎找不到的解決方法

最近寫了一個管理員後臺的web微服務,今天準備部署到阿里雲上,但是訪問頁面出現了

Whitelabel Error Page

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

Tue Mar 05 16:32:39 CST 2019

There was an unexpected error (type=Internal Server Error, status=500).

Error resolving template "/user/user-list", template might not exist or might not be accessible by any of the configured Template Resolvers

這個錯誤!玩過springboot的大佬們對這個錯誤已經不陌生了。然而我在IDEA上開發好好的,怎麼到服務器就不行了?我感覺是環境問題,然後我又打了一個jar運行在本機windows環境,然而還是這個錯誤!!

我發現首頁是好的,並且我是通過“/”轉發到首頁的,所以這個方法是正確的!然後我有看了一下別的請求方法,大家對比看一下有什麼區別:

在轉發的時候return前面加“/”的時候打成jar的時候找不到html頁面!

 

下面廢話少說,寫出解決方案:

把轉發的地址改爲 return "user/user-list";就可以了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章