有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JavaSpringFramework。数据领域页找不到字段“timestamp”的map SpelEvaluationException属性..”

我尝试实现分页支持。在成功地从服务中获取页面后,我想将其转换为以给定字符串作为主键的对象。寻呼后信息应保留

我尝试了以下方法:

Page<String> userIds = studentService.getAllUserIds(pageable);
Page<StudentStatistics> studentStatistics = userIds.map(new Converter<String, StudentStatistics>(){
            @Override
            public StudentStatistics convert(String userId) {
                return answerService.getUserStatistics(userId);
            }
        });

或:

List<StudentStatistics> studentStatistics = new ArrayList<StudentStatistics>();
    for(String userId : userIds){
        studentStatistics.add(answerService.getUserStatistics(userId));
    }
new PageImpl<>(studentStatistics, pageable, userIds.getTotalElements()));

两者都以例外告终:

org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'timestamp' cannot be found on object of type 'java.util.HashMap' - maybe not public?
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:81)
    at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120)
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:242)
    at org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$ExpressionResolver.resolvePlaceholder(ErrorMvcAutoConfiguration.java:279)
    at org.springframework.boot.autoconfigure.web.NonRecursivePropertyPlaceholderHelper$NonRecursivePlaceholderResolver.resolvePlaceholder(NonRecursivePropertyPlaceholderHelper.java:56)
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:147)
    at org.springframework.boot.autoconfigure.web.NonRecursivePropertyPlaceholderHelper.parseStringValue(NonRecursivePropertyPlaceholderHelper.java:38)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
    at org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView.render(ErrorMvcAutoConfiguration.java:217)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 
...

为什么在这种情况下会抛出此异常?页面实体是否具有时间戳属性

解决这个问题的优雅方法是什么

问候


更新:spel。SpelEvaluationException错误通常是在存储库模块的查询语法中出现错误时引起的。如果不使用本机查询,则可以使用Springs查询的Spel功能来面对此错误


共 (0) 个答案