Spring Boot常見問題的解決方式
阿新 • • 發佈:2018-12-08
- jsp無法自動重新整理
在application.properties檔案裡新增如下內容:
spring 1.5.5及 以上:server.jsp-servlet.init-parameters.development=true
spring boot2.0以上:server.servlet.jsp.init-parameters.development=true
如使用application.yml配置檔案,則將內容中的**“.”** 符號改為 “:” - 引用resources下的static靜態檔案
在application.properties檔案裡新增如下內容:
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:/static/
接著給jsp頁面等配置basePath
<% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %>
引用資源的例子
< link href=“static/bower_components/balloon-css/src/balloon.css” rel=“stylesheet” type=“text/css” />
3. There was an unexpected error (type=Internal Server Error, status=500).錯誤
若是使用jsp而不使用template模板,則需要關閉template模板,在application.properties檔案下新增以下程式碼
#關閉預設模板引擎 spring.thymeleaf.cache=false spring.thymeleaf.enabled=false