如何改变 java. util. Date 对象在 struts 2. 我测试过的东西, Struggs 2 接受 m/ d/yy。 是否可以修改格式?
如何更改默认消息“ 字段日期的无效字段值 ”?
在 struts2 中的日期标记只能用于输出 。
如何改变 java. util. Date 对象在 struts 2. 我测试过的东西, Struggs 2 接受 m/ d/yy。 是否可以修改格式?
如何更改默认消息“ 字段日期的无效字段值 ”?
在 struts2 中的日期标记只能用于输出 。
您可以通过格式到 s: date
标签
<s:date name="myDate" format="yyyy-MM-dd" />
要更改默认错误消息, 您可以在 validation. xml
中添加信件参数
<field name="myDate">
<field-validator type="date">
<message key="errors.myDateRequired" />
</field-validator>
</field>
然后在您的 ApplicationResources. propertys
文件中,您将为 errors.myDate required
提供价值。
更新:根据评论更新
s:date
只是一个只读标签, 表示无法接受用户输入 。
为使案文能够以不同格式接受日期,有几种办法:
您可以使用自定义转换器来使用日期的文本字段, < a href="https://stackoverflow.com/ questions/10750991/ no semethod expecation- in-struts2//10751705#107517051705" >example
Struts 接受的日期格式取决于用户的本地化 。 因此, 对于不同的本地化, 您可以有不同的本地化格式 。 这样您将无法支持同一本地化的多日期格式, 但我不明白为什么您需要这个格式, 它只会混淆您的用户 。 对于没有 Javascript 的同一本地化的本地化, 唯一支持不同日期格式的方法是使用@ mprabhat 便笺的自定义日期转换器 。
你可以看到官方关于这个文件:
定义每种语言的格式 y 资源捆绑。 例如, 适当的 en_ US 格式定义扩展名可能看起来是这样 :
format.date = {0,date,MM/dd/yy}
同时,您可以在您的 de_DE捆绑中添加以下内容:
format.date = {0,date,dd.MM.yyyy}
http://struts.apache.org/2.1.6/docs/formatting-dates-and-numbers.html
I m trying to integrate sitemesh into my struts2 app, but i m finding that it s not making any difference and isn t showing any errors (or anything sitemesh related at all) in the logs. I ve started ...
In Struts2, how do you share your common html across all pages? In Asp.net, you ve got Master pages, and in Rails there are Layouts. The idea is that your common html (eg the header, menu, and styles)...
Hey People. I have been recently validating Struts 2 actions. In One of my action class, the save method to be precise must have two id s. That is an assessmenttype id and a course id. this is what is ...
On default I want my struts2 app to forward to an action: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"...
I am a newbie into programming and i am currently employed as a junior programmer. I am currently having some problems validating the select tags in one of my forms. What i actually trying to do is to ...
How would I execute a method with an argument in my model based on the URL? Ie, http://server/MyAction_Arg.action maps to MyClass.MyMethod(Arg)? I tried this: <action name="MyAction_*" method="...
I am setting the value(kind of default value) for a drop down select value from action class in a page(given below). When the page loads the value is beig displayed but the other elements of the ...
I am developing a Struts 2 application with support for multiple languages. If one of the domain objects needs to throw an exception, how can it do so in such a way that the error message is no ...