Override Spring:message tag with database values

后端 未结 3 1999
小蘑菇
小蘑菇 2020-12-09 12:38

I am using Spring to display messages from a properties file. I would like to be able to override the tag to use a value from a database

3条回答
  •  被撕碎了的回忆
    2020-12-09 13:12

    You don't need to change the behaviour of , you just need to change the place it gets its messages from.

    By default, it uses the messageSource bean in the context, which is of type MessageSource, or some subclass thereof. You can write your own class that implements MessageSource and add that to your context as the messageSource bean.

    AbstractMessageSource is just a convenient starting point for writing your own MessageSource. It does some of the work for you, just subclass it.

提交回复
热议问题