【问题标题】:How to change value of code in <spring:message code>如何更改 <spring:message code> 中代码的值
【发布时间】:2012-06-11 13:57:14
【问题描述】:

在我的 html 中使用时遇到了麻烦。实际上我在 message.property 文件中定义了一些错误。

message.property:

spraying_schedule_master_unq1=Duplicate Record.
post_role_master_unq1=Record for This Applicable Date Already Exists.

如果控制器类中发生任何错误,我已将该错误设置为会话:

控制器:

session.setAttribute(SessionAttribute.error.toString(), error); 

我在 html 中显示的错误消息:

html:

<spring:message code="${error}" />

当发生错误时,它工作正常,如属性文件中定义的那样,但是当 sessoin 错误包含与属性文件不同的错误时,问题就开始了,此时它显示错误。所以我的问题是当属性文件中不存在错误消息时,它应该显示默认消息。我可以这样做吗,如果可以,怎么做?请给我一个解决方案,我被困在这里。谢谢

【问题讨论】:

    标签: javascript html spring spring-mvc


    【解决方案1】:
    <spring:message code="${error}" text="your default text here" />
    

    【讨论】:

      猜你喜欢
      • 2016-10-21
      • 2016-06-26
      • 1970-01-01
      • 2022-10-22
      • 2022-12-04
      • 1970-01-01
      • 2022-12-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多