我是Java/Spring/Thymeleaf的新手,所以请关注我目前的理解水平.我确实审查了这个类似的问题,但无法解决我的问题.
我想要一个简化的日期而不是长日期格式.
// DateTimeFormat annotation on the method that's calling the DB to get date.
@DateTimeFormat(pattern="dd-MMM-YYYY")
public Date getReleaseDate() {
return releaseDate;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<table>
<tr th:each="sprint : ${sprints}">
<td th:text="${sprint.name}"></td>
<td th:text="${sprint.releaseDate}"></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
电流输出
sprint1 2016-10-04 14:10:42.183
Run Code Online (Sandbox Code Playgroud) Spring-boot v1.4.1
Java v1.8
Thymeleaf v2.1.5.
我视图中的以下代码行:
<td th:each = "sprint : ${sprints}" th:text = "${sprint.releaseDate} ? ${#temporals.format(sprint.releaseDate, 'MMM/dd/yyyy')}"></td>
Run Code Online (Sandbox Code Playgroud)
我有基于SO问题SpringBoot Thymeleaf Ordinal Numbers的语法产生错误:
org.springframework.expression.spel.SpelEvaluationException:EL1011E:(pos 11):方法调用:尝试在空上下文对象上调用方法格式(java.time.LocalDate,java.lang.String)
但是,如果我在没有Thymeleaf格式的情况下运行这行代码,它将工作并以默认格式呈现LocalDate对象表("2016-05-25").
问题:为什么我收到'空上下文对象'错误,这是什么意思?我如何编辑以获得我想要的格式?
var test = ['hello', 'Hello']
var arg1 = test[0].split('').sort().join('').toLowerCase(); // ehllo
var arg2 = test[1].split('').sort().join('').toLowerCase(); // hello
Run Code Online (Sandbox Code Playgroud)
有人能够解释为什么sort方法似乎对测试数组的第二个元素没有影响吗?