struts2 的 属性 标签属性无法解析 value="(new java.text.SimpleDateFormat("").format())" 在 struts2 版本 2.3.32

struts2's property tag attribute cant resolve value="(new java.text.SimpleDateFormat("").format())" at struts2 version 2.3.32

我在将 Struts2 从版本 2.3.15 更新到 2.3.32 时遇到了这个问题。在 2.3.32 版本, <s:property value="(new java.text.SimpleDateFormat().format())"> 无法解析,并且没有错误。那么,如何解决这个问题呢?

与其在 属性 标记中编写难看的 OGNL 表达式,那甚至不起作用,为什么不在操作 class 中创建一个确实格式化值的 property/method。

How to format dates and numbers:

A frequently asked question is how best to display dates and numbers using a specified format. There are a number of approaches for this, the most naive of which would be to add a method to your action class to do the formatting for you. This method would take in a Date (or subclass) object as a parameter, and return a formatted String.