項目中使用了thymeleaf,本地運行沒有任何問題,然後將Springboot項目部署到Linux服務器上,跳轉動態頁面的時候,就出現瞭如下問題:
報錯:
There was an unexpected error (type=Internal Server Error, status=500).Request processing failed;nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template....
一、原因在於,本地Windows上,和Linux雲服務器上的路徑寫法不一樣:
Windows上:return "/page1/page2";
Linux服務器上:return "page1/page2";
其實就是去掉路徑最前面的 " / " 。
不過在查詢資料的時候,還發現另一種可能會引起次錯誤的原因以及解決辦法,這裏也記錄一下:
二、Linux服務器上的路徑區分大小寫。
路徑是 /Page1/page2 ;
windows上,可用不區分路徑大小寫:return "/page1/page2";
Linux上,需要嚴格區分路徑的大小寫:return "Page1/page2";