報錯信息如下:
Whitelabel Error Page
This application has no explicit mapping
for / error
, so you are seeing
this as a fallback
. Wed Mar
25 17 : 38 : 33 CST
2020
There was an unexpected error
( type
= Internal Server Error
, status
= 500 ) .
An error happened during template parsing
( template
: "class path resource [templates/emp/list.html]" )
網上很多博主都說是因為文件開頭加了 https: xmlns:https="http://www.w3.org/1999/xhtml" 和 xmlns:th="http://www.thymeleaf.org" 沖突了
而我認為不以為然
具體的原因就是你在使用thymeleaf模板的時候語法錯誤,另一種說法加入你跳轉到list.html頁面的時候出現這個報錯,那么證明list.html頁面里面有語法錯誤,請仔細檢查
下面我展示一下我的錯誤:
錯誤代碼:(取值的時候多了一個大括號)
正確代碼:
其實有時候你也可以通過控制臺得到錯誤的地方,看以下報錯的最后一行 Caused by: org.attoparser.ParseException: Could not parse as expression: “${emp.lastName}}” (template: “emp/list” - line 197, col 17) 錯誤在197行,17列
org
. thymeleaf
. exceptions
. TemplateInputException
: An error happened during template parsing
( template
: "class path resource [templates/emp/list.html]" ) at org
. thymeleaf
. templateparser
. markup
. AbstractMarkupTemplateParser
. parse ( AbstractMarkupTemplateParser
. java
: 241 ) ~ [ thymeleaf
- 3.0 .11 . RELEASE
. jar
: 3.0 .11 . RELEASE
] at org
. thymeleaf
. templateparser
. markup
. AbstractMarkupTemplateParser
. parseStandalone ( AbstractMarkupTemplateParser
. java
: 100 ) ~ [ thymeleaf
- 3.0 .11 . RELEASE
. jar
: 3.0 .11 . RELEASE
] at org
. thymeleaf
. engine
. TemplateManager
. parseAndProcess ( TemplateManager
. java
: 666 ) ~ [ thymeleaf
- 3.0 .11 . RELEASE
. jar
: 3.0 .11 . RELEASE
] at org
. thymeleaf
. TemplateEngine
. process ( TemplateEngine
. java
: 1098 ) [ thymeleaf
- 3.0 .11 . RELEASE
. jar
: 3.0 .11 . RELEASE
] at org
. thymeleaf
. TemplateEngine
. process ( TemplateEngine
. java
: 1072 ) [ thymeleaf
- 3.0 .11 . RELEASE
. jar
: 3.0 .11 . RELEASE
] at org
. thymeleaf
. spring5
. view
. ThymeleafView
. renderFragment ( ThymeleafView
. java
: 362 ) [ thymeleaf
- spring5
- 3.0 .11 . RELEASE
. jar
: 3.0 .11 . RELEASE
] at org
. thymeleaf
. spring5
. view
. ThymeleafView
. render ( ThymeleafView
. java
: 189 ) [ thymeleaf
- spring5
- 3.0 .11 . RELEASE
. jar
: 3.0 .11 . RELEASE
] at org
. springframework
. web
. servlet
. DispatcherServlet
. render ( DispatcherServlet
. java
: 1373 ) [ spring
- webmvc
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. springframework
. web
. servlet
. DispatcherServlet
. processDispatchResult ( DispatcherServlet
. java
: 1118 ) [ spring
- webmvc
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. springframework
. web
. servlet
. DispatcherServlet
. doDispatch ( DispatcherServlet
. java
: 1057 ) [ spring
- webmvc
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. springframework
. web
. servlet
. DispatcherServlet
. doService ( DispatcherServlet
. java
: 943 ) [ spring
- webmvc
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. springframework
. web
. servlet
. FrameworkServlet
. processRequest ( FrameworkServlet
. java
: 1006 ) [ spring
- webmvc
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. springframework
. web
. servlet
. FrameworkServlet
. doGet ( FrameworkServlet
. java
: 898 ) [ spring
- webmvc
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at javax
. servlet
. http
. HttpServlet
. service ( HttpServlet
. java
: 634 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. springframework
. web
. servlet
. FrameworkServlet
. service ( FrameworkServlet
. java
: 883 ) [ spring
- webmvc
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at javax
. servlet
. http
. HttpServlet
. service ( HttpServlet
. java
: 741 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. ApplicationFilterChain
. internalDoFilter ( ApplicationFilterChain
. java
: 231 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. ApplicationFilterChain
. doFilter ( ApplicationFilterChain
. java
: 166 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. tomcat
. websocket
. server
. WsFilter
. doFilter ( WsFilter
. java
: 53 ) [ tomcat
- embed
- websocket
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. ApplicationFilterChain
. internalDoFilter ( ApplicationFilterChain
. java
: 193 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. ApplicationFilterChain
. doFilter ( ApplicationFilterChain
. java
: 166 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. springframework
. web
. filter
. RequestContextFilter
. doFilterInternal ( RequestContextFilter
. java
: 100 ) [ spring
- web
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. springframework
. web
. filter
. OncePerRequestFilter
. doFilter ( OncePerRequestFilter
. java
: 119 ) [ spring
- web
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. apache
. catalina
. core
. ApplicationFilterChain
. internalDoFilter ( ApplicationFilterChain
. java
: 193 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. ApplicationFilterChain
. doFilter ( ApplicationFilterChain
. java
: 166 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. springframework
. web
. filter
. FormContentFilter
. doFilterInternal ( FormContentFilter
. java
: 93 ) [ spring
- web
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. springframework
. web
. filter
. OncePerRequestFilter
. doFilter ( OncePerRequestFilter
. java
: 119 ) [ spring
- web
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. apache
. catalina
. core
. ApplicationFilterChain
. internalDoFilter ( ApplicationFilterChain
. java
: 193 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. ApplicationFilterChain
. doFilter ( ApplicationFilterChain
. java
: 166 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. springframework
. web
. filter
. CharacterEncodingFilter
. doFilterInternal ( CharacterEncodingFilter
. java
: 201 ) [ spring
- web
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. springframework
. web
. filter
. OncePerRequestFilter
. doFilter ( OncePerRequestFilter
. java
: 119 ) [ spring
- web
- 5.2 .4 . RELEASE
. jar
: 5.2 .4 . RELEASE
] at org
. apache
. catalina
. core
. ApplicationFilterChain
. internalDoFilter ( ApplicationFilterChain
. java
: 193 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. ApplicationFilterChain
. doFilter ( ApplicationFilterChain
. java
: 166 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. StandardWrapperValve
. invoke ( StandardWrapperValve
. java
: 202 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. StandardContextValve
. invoke ( StandardContextValve
. java
: 96 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. authenticator
. AuthenticatorBase
. invoke ( AuthenticatorBase
. java
: 541 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. StandardHostValve
. invoke ( StandardHostValve
. java
: 139 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. valves
. ErrorReportValve
. invoke ( ErrorReportValve
. java
: 92 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. core
. StandardEngineValve
. invoke ( StandardEngineValve
. java
: 74 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. catalina
. connector
. CoyoteAdapter
. service ( CoyoteAdapter
. java
: 343 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. coyote
. http11
. Http11Processor
. service ( Http11Processor
. java
: 367 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. coyote
. AbstractProcessorLight
. process ( AbstractProcessorLight
. java
: 65 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. coyote
. AbstractProtocol$ConnectionHandler
. process ( AbstractProtocol
. java
: 868 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. tomcat
. util
. net
. NioEndpoint$SocketProcessor
. doRun ( NioEndpoint
. java
: 1639 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at org
. apache
. tomcat
. util
. net
. SocketProcessorBase
. run ( SocketProcessorBase
. java
: 49 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at java
. util
. concurrent
. ThreadPoolExecutor
. runWorker ( ThreadPoolExecutor
. java
: 1142 ) [ na
: 1.8 .0 _77
] at java
. util
. concurrent
. ThreadPoolExecutor$Worker
. run ( ThreadPoolExecutor
. java
: 617 ) [ na
: 1.8 .0 _77
] at org
. apache
. tomcat
. util
. threads
. TaskThread$WrappingRunnable
. run ( TaskThread
. java
: 61 ) [ tomcat
- embed
- core
- 9.0 .31 . jar
: 9.0 .31 ] at java
. lang
. Thread
. run ( Thread
. java
: 745 ) [ na
: 1.8 .0 _77
]
Caused by
: org
. attoparser
. ParseException
: Could not parse as expression
: "${emp.lastName}}" ( template
: "emp/list" - line
197 , col
17 )
如果此篇文章對你有幫助,請記得點贊哦!
總結
以上是生活随笔 為你收集整理的An error happened during template parsing (template: class path resource [templates/emp/list.html] 的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔 網站內容還不錯,歡迎將生活随笔 推薦給好友。