Что вызывает «Исключение, оценивающее выражение SpringEL:» в Thymeleaf? - PullRequest
0 голосов
/ 24 марта 2020

Ошибка указывает на эту строку:

Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "#numbers.sequence( pageNumber + 1, patientsPage.totalPages > 10 + pageNumber ? pageNumber + 10 : patientsPage.totalPages, 1)"

Что не так с этим выражением? Разве это не правильный способ суммирования?

Вот мой код:

    <li class="page-item"
    th:classappend="${i eq pageNumber + 1} ? 'active'"
    th:each="i : ${#numbers.sequence( pageNumber + 1, patientsPage.totalPages > 10 + pageNumber ? pageNumber + 10 : patientsPage.totalPages, 1)}">
    <a class="page-link" th:text="${i}"
    th:title="${'Page '+ i}" rel="tooltip"></a>
    </li>

Stacktrace:

2020-03-24 14: 06: 35.440 ОШИБКА 43588 - - [nio-8081-exe c -3] org.thymeleaf.TemplateEngine: [THYMELEAF] [http-nio-8081-exe c -3] Шаблон "Exams" для обработки исключений: во время синтаксического анализа произошла ошибка (template: "ресурс пути к классу [templates / exams.html]")

org.thymeleaf.exceptions.TemplateInputException: произошла ошибка при разборе шаблона (template: "ресурс пути к классу [templates / exams.html] ") в org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse (AbstractMarkupTemplateParser. java: 241) ~ [thymeleaf-3.0.9.RELEASE.jar: 3.0.9.RELEASE] в org.thymelearser.markup.markate. AbstractMarkupTemplateParser.parseStandalone (AbstractMarkupTemplateParser. java: 100) ~ [thymeleaf-3.0.9.RELEASE.jar: 3.0.9.RELEASE] в org.thymeleaf.engine.TemplateManager.parseAndProcess * 1018: 6: 6Mager. [thymeleaf-3.0.9.RELEASE.jar: 3.0.9.RELEASE] в или g.thymeleaf.TemplateEngine.process (TemplateEngine. java: 1098) [thymeleaf-3.0.9.RELEASE.jar: 3.0.9.RELEASE] в org.thymeleaf.TemplateEngine.process (TemplateEngine. java: 1072) [thymeleaf-3.0.9.RELEASE.jar: 3.0.9.RELEASE] в org.thymeleaf.spring5.view.ThymeleafView.renderFragment (ThymeleafView. java: 354) [thymeleaf-spring5-3.0.9.RELEASE.jar : 3.0.9.RELEASE] в org.thymeleaf.spring5.view.ThymeleafView.render (ThymeleafView. java: 187) [thymeleaf-spring5-3.0.9.RELEASE.jar: 3.0.9.RELEASE] в орг. springframework.web.servlet.DispatcherServlet.render (DispatcherServlet. java: 1325) [spring-web mvc -5.0.9.RELEASE.jar: 5.0.9.RELEASE] в org.springframework.web.servlet.DispatcherServlet .processDispatchResult (DispatcherServlet. java: 1069) [spring-web mvc -5.0.9.RELEASE.jar: 5.0.9.RELEASE] в org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet. * *: 1008) [spring-web mvc -5.0.9.RELEASE.jar: 5.0.9.RELEASE] по адресу org.springframework.web.servlet.DispatcherServlet.doService (Dispatc herServlet. java: 925) [spring-web mvc -5.0.9.RELEASE.jar: 5.0.9.RELEASE] в org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet. java: 974) ) [spring-web mvc -5.0.9.RELEASE.jar: 5.0.9.RELEASE] по адресу org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet. java: 866) [spring-web mvc -5.0.9.RELEASE.jar: 5.0.9.RELEASE] по адресу javax.servlet.http.HttpServlet.service (HttpServlet. java: 635) [tomcat-embed-core-8.5.34.jar: 8.5. 34] в org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet. java: 851) [spring-web mvc -5.0.9.RELEASE.jar: 5.0.9.RELEASE] в javax.servlet. http.HttpServlet.service (HttpServlet. java: 742) [tomcat-embed-core-8.5.34.jar: 8.5.34] в org. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. * 1040) *: 231) [tomcat-embed-core-8.5.34.jar: 8.5.34] в орг. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) [tomcat-embed-core -8.5.34.jar: 8.5.34] в орг. apache .tomca t.websocket.server.WsFilter.doFilter (WsFilter. java: 52) [tomcat-embed-websocket-8.5.34.jar: 8.5.34] в орг. apache .catalina.core.ApplicationFilterChain.internalDoFilter ( ApplicationFilterChain. java: 193) [tomcat-embed-core-8.5.34.jar: 8.5.34] в org. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) [tomcat -embed-core-8.5.34.jar: 8.5.34] at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 320) [spring-security-web-5.0.8.RELEASE .jar: 5.0.8.RELEASE] в org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke (FilterSecurityInterceptor. java: 127) [spring-security-web-5.0.8.RELEASE.jar: 5.0 .8.RELEASE] at org.springframework.security.web.access.intercept. FilterSecurityInterceptor.doFilter (FilterSecurityInterceptor. java: 91) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFinProC (фильтр) java: 334) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] по адресу org.springframework.security.web.access.ExceptionTranslationFilter.doFilter (ExceptionTranslationFilter. java: 119) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 334) [spring-security-web -5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web.session.SessionManagementFilter.doFilter (SessionManagementFilter. java: 137) [spring-security-web-5.0.8.RELEASE .jar: 5.0.8.RELEASE] at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 334) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8 .RELEASE] at org.springframework.security.web.authent ication.AnonymousAuthenticationFilter.doFilter (AnonymousAuthenticationFilter. java: 111) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web.FilterChainProxy $ VirtualFilterChain. FilterChainProxy. java: 334) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter (SecurityContextHolderAterRequest 170) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 334) [spring-security -web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter (RequestCacheAwareFilter. java: 63) [spring-security-web-5.0.8 .RELEASE.jar: 5.0.8.RELEASE] at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 334) [spring-security-web-5.0.8.RELEASE.jar: 5.0 .8.R ELEASE] at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter (AbstractAuthenticationProcessingFilter. java: 200) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springra .security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 334) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web.authentication .logout.LogoutFilter.doFilter (LogoutFilter. java: 116) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 334) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web.csrf.CsrfFilter.doFilterInternal (CsrfFilter. java) : 100) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] по адресу org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) [spring-web- 5.0.9.RELEASE.jar: 5.0.9.RELEASE] на org.spring framework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 334) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.security.web. header.HeaderWriterFilter.doFilterInternal (HeaderWriterFilter. java: 66) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework.web.filter.OncePerRequestFilter.doFilter (OnceP. java: 107) [spring-web-5.0.9.RELEASE.jar: 5.0.9.RELEASE] в org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 334) [пружина -security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter (SecurityContextPersistenceFilter. java: 105) [spring-security-web-5.0 .8.RELEASE.jar: 5.0.8.RELEASE] at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 334) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] по адресу org.springframework.security.web.context.request.asyn c .WebAsyncManagerIntegrationFilter.doFilterInternal (WebAsyncMilterInte . java: 56) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] по адресу org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) [ spring-web-5.0.9.RELEASE.jar: 5.0.9.RELEASE] в org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. java: 334) [spring-security-web-5.0. 8.RELEASE.jar: 5.0.8.RELEASE] at org.springframework.security.web.FilterChainProxy.doFilterInternal (FilterChainProxy. java: 215) [spring-security-web-5.0.8.RELEASE.jar: 5.0. 8.RELEASE] в org.springframework.security.web.FilterChainProxy.doFilter (FilterChainProxy. java: 178) [spring-security-web-5.0.8.RELEASE.jar: 5.0.8.RELEASE] в org.springframework .web.filter.DelegatingFilterProxy.invokeDelegate (DelegatingFilterProxy. java: 357) [spring-web-5. 0.9.RELEASE.jar: 5.0.9.RELEASE] at org.springframework.web.filter.DelegatingFilterProxy.doFilter (DelegatingFilterProxy. java: 270) [spring-web-5.0.9.RELEASE.jar: 5.0.9. RELEASE] at org. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) [tomcat-embed-core-8.5.34.jar: 8.5.34] в орг. apache .catalina .core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) [tomcat-embed-core-8.5.34.jar: 8.5.34] по адресу org.springframework.web.filter.RequestContextFilter * (). : 99) [spring-web-5.0.9.RELEASE.jar: 5.0.9.RELEASE] по адресу org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) [spring-web-5.0. 9.RELEASE.jar: 5.0.9.RELEASE] at org. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) [tomcat-embed-core-8.5.34.jar: 8.5. 34] at org. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) [tomcat-embed-core-8.5.3 4.jar: 8.5.34] at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal (HttpPutFormContentFilter. java: 109) [spring-web-5.0.9.RELEASE.jar: 5.0.9.RELEASE] в org .springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) [spring-web-5.0.9.RELEASE.jar: 5.0.9.RELEASE] в организации. apache .catalina.core.ApplicationFilterChain .internalDoFilter (ApplicationFilterChain. java: 193) [tomcat-embed-core-8.5.34.jar: 8.5.34] в org. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166 ) [tomcat-embed-core-8.5.34.jar: 8.5.34] в org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal (HiddenHttpMethodFilter. java: 93) [spring-web-5.0.9.RELEASE. jar: 5.0.9.RELEASE] в org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) [spring-web-5.0.9.RELEASE.jar: 5.0.9.RELEASE] в организации . apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) [tomcat-embed- core-8.5.34.jar: 8.5.34] at org. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) [tomcat-embed-core-8.5.34.jar: 8.5. 34] at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal (SessionRepositoryFilter. java: 147) [spring-session-core-2.0.6.RELEASE.jar: 2.0.6.RELEASE] в org.springframework .session.web.http.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 81) [spring-session-core-2.0.6.RELEASE.jar: 2.0.6.RELEASE] в орг. apache .catalina.core .ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) [tomcat-embed-core-8.5.34.jar: 8.5.34] в орг. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. * 11 : 166) [tomcat-embed-core-8.5.34.jar: 8.5.34] в org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (CharacterEncodingFilter. java: 200) [spring-web-5.0.9. РЕЛИЗ. jar: 5.0.9.RELEASE] в org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) [spring-web-5.0.9.RELEASE.jar: 5.0.9.RELEASE] в организации . apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) [tomcat-embed-core-8.5.34.jar: 8.5.34] в орг. apache .catalina.core.ApplicationFilterChain .doFilter (ApplicationFilterChain. java: 166) [tomcat-embed-core-8.5.34.jar: 8.5.34] в org. apache .catalina.core.StandardWrapperValve.invoke (StandardWrapperValve. java: 198 ) [tomcat-embed-core-8.5.34.jar: 8.5.34] в орг. apache .catalina.core.StandardContextValve.invoke (StandardContextValve. java: 96) [tomcat-embed-core-8.5. 34.jar: 8.5.34] в орг. apache .catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase. java: 493) [tomcat-embed-core-8.5.34.jar: 8.5.34] в орг. . apache .catalina.core.StandardHostValve.invoke (StandardHostValve. java: 140) [tomcat-embed-core-8.5.34.jar: 8.5.34] в орг. apache .catalina.valves.ErrorReportValve .invoke (ErrorRe portValve. java: 81) [tomcat-embed-core-8.5.34.jar: 8.5.34] в орг. apache .catalina.core.StandardEngineValve.invoke (StandardEngineValve. java: 87) [tomcat -embed-core-8.5.34.jar: 8.5.34] в орг. apache .catalina.connector.CoyoteAdapter.service (CoyoteAdapter. java: 342) [tomcat-embed-core-8.5.34.jar : 8.5.34] at org. apache .coyote.http11.Http11Processor.service (Http11Processor. java: 800) [tomcat-embed-core-8.5.34.jar: 8.5.34] в org. apache .coyote.AbstractProcessorLight.process (AbstractProcessorLight. java: 66) [tomcat-embed-core-8.5.34.jar: 8.5.34] at org. apache .coyote.AbstractProtocol $ ConnectionHandler.process (AbstractProtocol. java: 806) [tomcat-embed-core-8.5.34.jar: 8.5.34] в орг. apache .tomcat.util. net .NioEndpoint $ SocketProcessor.doRun (NioEndpoint. java: 1498) [tomcat-embed-core-8.5.34.jar: 8.5.34] в орг. apache .tomcat.util. net .SocketProcessorBase.run (SocketProcessorBase. java: 49) [tomcat-embed -core-8.5.34.jar: 8.5.34] в java .util.concurrent.ThreadPoolExecutor.runWorker (неизвестный источник ) [na: 1.8.0_241] в java .util.concurrent.ThreadPoolExecutor $ Worker.run (неизвестный источник) [na: 1.8.0_241] в орг. apache .tomcat.util.threads.TaskThread $ WrappingRunnable. run (TaskThread. java: 61) [tomcat-embed-core-8.5.34.jar: 8.5.34] в java .lang.Thread.run (неизвестный источник) [na: 1.8.0_241] Вызвано : org.attoparser.ParseException: Исключение, оценивающее выражение SpringEL: "# numbers.sequence (pageNumber + 1, PatientPage.totalPages> 10 + pageNumber? pageNumber + 10: PatientPage.totalPages, 1) "(шаблон:" экзамены "- строка 114, столбец 15) в org.attoparser.MarkupParser.parseDocument (MarkupParser. java: 393) ~ [attoparser-2.0.4.RELEASE .jar: 2.0.4.RELEASE] в org.attoparser.MarkupParser.parse (MarkupParser. java: 257) ~ [attoparser-2.0.4.RELEASE.jar: 2.0.4.RELEASE] в org.thymeleaf.templateparser .markup.AbstractMarkupTemplateParser.parse (AbstractMarkupTemplateParser. java: 230) ~ [thymeleaf-3.0.9.RELEASE.jar: 3.0.9.RELEASE] ... опущено 91 общих фреймов. : Исключительная ситуация при вычислении выражения SpringEL: "# numbers.sequence (pageNumber + 1, PatientPage.totalPages> 10 + pageNumber? PageNumber + 10: PatientPage.totalPages, 1)" (шаблон: "экзамены" - строка 114, столбец 15) в орг. .thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate (SPELVariableExpressionEvaluator. java: 290) ~ [thymeleaf-spring5-3.0.9.RELEASE.jar: 3.0.9.RELEASE] в орг.thymeleaf.standard.Express n.executeVariableExpression (VariableExpression. java: 165) ~ [thymeleaf-3.0.9.RELEASE.jar: 3.0.9.RELEASE]

1 Ответ

0 голосов
/ 25 марта 2020

Согласно эти :

< и > не должны использоваться в значениях атрибутов, поэтому их следует заменить на &lt; и &gt;

Более простой альтернативой может быть использование текстовых псевдонимов, которые существуют для некоторых из этих операторов: gt (>), lt (<), ge (>=) , le (<=), not (!). Также eq (==), neq/ne (!=).

th:each="i : ${#numbers.sequence(pageNumber + 1, patientsPage.totalPages gt 10 + pageNumber ? pageNumber + 10 : patientsPage.totalPages, 1)}">

или

th:each="i : ${#numbers.sequence(pageNumber + 1, patientsPage.totalPages &gt; 10 + pageNumber ? pageNumber + 10 : patientsPage.totalPages, 1)}">

должны работать оба.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...