У меня есть список, в котором содержится такая карта:
Map<String, Long> count = new HashMap<>();
count.put("totalMessageCount", 5L);
Map<String, Map<String, Long>> names = new HashMap<>();
names.put("someKey", count);
List<Map<String, Map<String, Long>>> list = new ArrayList<>();
list.add(names);
Я отправляю этот список из контроллера в View.
Я пробовал это:
<table>
<tr th:each="element : ${list}">
<td th:text="${element.key}"></td>
<td th:text="${element.value}"></td>
</table>
Я получаю ошибку:
org.springframework.expression.spel.SpelEvaluationException: EL1008E: Свойство или поле 'ключ' не могут быть найдены для объекта типа 'java.util.HashMap' - может быть, не является общедоступным или недействительным?
в org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty (PropertyOrFieldReference.java:217)
в org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal (PropertyOrFieldReference.java:104)
в org.springframework.expression.spel.ast.PropertyOrFieldReference.access $ 000 (PropertyOrFieldReference.java:51)
в org.springframework.expression.spel.ast.PropertyOrFieldReference $ AccessorLValue.getValue (PropertyOrFieldReference.java:406)
в org.springframework.expression.spel.ast.CompoundExpression.getValueInternal (CompoundExpression.java:90)
в org.springframework.expression.spel.ast.SpelNodeImpl.getValue (SpelNodeImpl.java:109)
в org.springframework.expression.spel.standard.SpelExpression.getValue (SpelExpression.java:328)
в org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate (SPELVariableExpressionEvaluator.java:263)
в org.thymeleaf.standard.expression.VariableExpression.executeVariableExpression (VariableExpression.java:166)
в org.thymeleaf.standard.expression.SimpleExpression.executeSimple (SimpleExpression.java:66)
в org.thymeleaf.standard.expression.Expression.execute (Expression.java:109)
в org.thymeleaf.standard.expression.AdditionExpression.executeAddition (AdditionExpression.java:96)
в org.thymeleaf.standard.expression.ComplexExpression.executeComplex (ComplexExpression.java:62)
в org.thymeleaf.standard.expression.Expression.execute (Expression.java:112)
в org.thymeleaf.standard.expression.Expression.execute (Expression.java:138)
в org.thymeleaf.standard.processor.AbstractStandardExpressionAttributeTagProcessor.doProcess (AbstractStandardExpressionAttributeTagProcessor.java:144)
в org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess (AbstractAttributeTagProcessor.java:74)
в org.thymeleaf.processor.element.AbstractElementTagProcessor.process (AbstractElementTagProcessor.java:95)
в org.thymeleaf.util.ProcessorConfigurationUtils $ ElementTagProcessorWrapper.process (ProcessorConfigurationUtils.java:633)
в org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement (ProcessorTemplateHandler.java:1314)
в org.thymeleaf.engine.OpenElementTag.beHandled (OpenElementTag.java:205)
в org.thymeleaf.engine.Model.process (Model.java:282)
в org.thymeleaf.engine.Model.process (Model.java:290)
в org.thymeleaf.engine.IteratedGatheringModelProcessable.processItivationModel (IteratedGatheringModelProcessable.java:367)
в org.thymeleaf.engine.IteratedGatheringModelProcessable.process (IteratedGatheringModelProcessable.java:221)
в org.thymeleaf.engine.ProcessorTemplateHandler.handleCloseElement (ProcessorTemplateHandler.java:1640)
в org.thymeleaf.engine.CloseElementTag.beHandled (CloseElementTag.java:139)
в org.thymeleaf.engine.Model.process (Model.java:282)
в org.thymeleaf.engine.Model.process (Model.java:290)
в org.thymeleaf.engine.IteratedGatheringModelProcessable.processItivationModel (IteratedGatheringModelProcessable.java:367)
в org.thymeleaf.engine.IteratedGatheringModelProcessable.process (IteratedGatheringModelProcessable.java:221)
в org.thymeleaf.engine.ProcessorTemplateHandler.handleCloseElement (ProcessorTemplateHandler.java:1640)
в org.thymeleaf.engine.CloseElementTag.beHandled (CloseElementTag.java:139)
в org.thymeleaf.engine.Model.process (Model.java:282)
в org.thymeleaf.engine.Model.process (Model.java:290)по адресу org.thymeleaf.engine.IteratedGatheringModelProcessable.processIterationModel (IteratedGatheringModelProcessable.java:367) по адресу org.thymeleaf.engine.IteratedGatheringModelProcessable.process (IteratedGatheringModelProcessable.forle.HeleTeleHeleTlayer.Hlayer.Hell_HL_W0_L_L_L_W_W_W_L_E_L_W_L_E_L_W_L_E_W_L_E_L_E_L_E_L_E_L_E_t_L_W_)) в org.thymeleaf.engine.CloseElementTag.beHandled (CloseElementTag.java:139) в org.thymeleaf.engine.TemplateModel.process (TemplateModel.java:136) в org.thymeleaf.engine.TemplateManager.jse: TemplateManager.pse661) в org.thymeleaf.TemplateEngine.process (TemplateEngine.java:1098) в org.thymeleaf.TemplateEngine.process (TemplateEngine.java:1072) в org.thymeleaf.spring5.view.ThymeleafView.renderFragment: Thymeleaf) в org.thymeleaf.spring5.view.ThymeleafView.render (ThymeleafView.java:189) в org.springframework.web.servlet.DispatcherServlet.render (DispatcherServlet.java:1370) в org.springframework.leterSletlet.прocessDispatchResult (DispatcherServlet.java:1116) по адресу org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:1055) по адресу org.springframework.web.servlet.DispatcherServlet.jpg: spr..web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:1005) в org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:897) в javax.servlet.http.HttpServlet.Servlet.Servlet.) по адресу org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:882) по адресу javax.servlet.http.HttpServlet.service (HttpServlet.java:741) по адресу org.apache.catalina.cil.FinApplicationFilterChain.java:231) по адресу org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) по адресу org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.gap. org):.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) вorg.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) по адресу org.springframework.web.filter.RequestContextFilter.doFilterInternal (RequestContextFilter.java:99.FilterFerterFraF) в org.squOncePerRequestFilter.java:107) в org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) в org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilter.f..filter.FormContentFilter..ilter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) в org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) в org.apache.catalina.cil6FFF (по адресу org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (CharacterEncodingFilter.java:200) по адресу org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.in.hain.Finter.Fineter.Cat.F:(ApplicationFilterChain.java:193) в org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) в org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java)в org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:96)
в org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:490)
в org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:139)
в org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:92)
в org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:74)
в org.apache.catalina.valves.AbstractAccessLogValve.invoke (AbstractAccessLogValve.java:668)
в org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:343)
в org.apache.coyote.http11.Http11Processor.service (Http11Processor.java:408)
в org.apache.coyote.AbstractProcessorLight.process (AbstractProcessorLight.java:66)
в org.apache.coyote.AbstractProtocol $ ConnectionHandler.process (AbstractProtocol.java:834)
в org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun (NioEndpoint.java:1415)
в org.apache.tomcat.util.net.SocketProcessorBase.run (SocketProcessorBase.java:49)
в java.base / java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1135)
в java.base / java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:635)
в org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run (TaskThread.java:61)
в java.base / java.lang.Thread.run (Thread.java:844)
Любая помощь приветствуется.