简体   繁体   English

struts2的属性标记属性无法解析value =“(new java.text.SimpleDateFormat(”“)。format())”at struts2 version 2.3.32

[英]struts2's property tag attribute cant resolve value=“(new java.text.SimpleDateFormat(”“).format())” at struts2 version 2.3.32

i was encounter this problem when i update the Struts2 from version 2.3.15 to 2.3.32. 当我将Struts2从版本2.3.15更新到2.3.32时,我遇到了这个问题。 At version 2.3.32 , <s:property value="(new java.text.SimpleDateFormat().format())"> could not be parsed,and no error. 在版本2.3.32, <s:property value="(new java.text.SimpleDateFormat().format())">无法解析,并且没有错误。 So, how to resolve this problem? 那么,如何解决这个问题呢?

Instead of writing ugly OGNL expression in property tag, that even doesn't work, why not to create a property/method in action class that does format the value. 而不是在属性标记中编写丑陋的OGNL表达式,甚至不起作用,为什么不在动作类中创建一个格式化值的属性/方法。

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 . 此方法将Date (或子类)对象作为参数,并返回格式化的String


声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM