【问题标题】:Front end label configuration in springspring中的前端标签配置
【发布时间】:2015-03-12 13:37:19
【问题描述】:

我希望我的网络应用程序中的每个 jsp 页面都有一个 external property(具有标签名称和值对)。

我已经这样做了,就像简单地在 Map 中读取属性文件并使用 expression language 放置在 jsp 中一样。

还有其他方法可以在 Java/Spring 中处理这些问题吗?

【问题讨论】:

    标签: java spring jakarta-ee jstl


    【解决方案1】:

    您可以将这些作为消息属性

    http://www.mkyong.com/spring-mvc/spring-mvc-internationalization-example/

    这也详细解释了这一点 - http://www.journaldev.com/2610/spring-mvc-internationalization-i18n-and-localization-l10n-example

    如果您需要这些按区域设置,您也可以使用 localechangeInterceptor。

    您可以将 PropertyPlaceholderConfigurer 用于外部属性(例如 systemPropertiesMode 属性)

    http://www.summa-tech.com/blog/2009/04/20/6-tips-for-managing-property-files-with-spring

    还有更多方法可以做到这一点,例如http://howtodoinjava.com/2015/01/27/how-to-load-external-resources-files-into-spring-context/

    <bean id="messageSource"
    class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename">
            <value>locale\customer\messages</value>
        </property>
    </bean>
    

    spring mvc and ReloadableResourceBundleMessageSource

    【讨论】:

    • 我已经提到了这个,但这不是我的范围。我想将属性文件保存在外部(WAR 之外)。
    • PropertyPlaceholderConfigurer 怎么样?这有帮助吗?
    • 我也在为应用程序中的每个 jsp 寻找单独的配置属性。
    • PropertyPlaceholderConfigurer 能完成这项工作吗?
    【解决方案2】:

    是的,春天还有另一种显示标签的方法,这是最佳实践代码。

    enter link description here 这将解释如何在你的项目中使用&lt;spring:message code="label.viewUser" /&gt;

    【讨论】:

      猜你喜欢
      • 2013-06-01
      • 2017-04-07
      • 2021-01-02
      • 2018-12-22
      • 2014-05-09
      • 2020-04-02
      • 2020-07-14
      • 2020-09-16
      • 1970-01-01
      相关资源
      最近更新 更多