使用数据库值覆盖 Spring:message 标记 [英] Override Spring:message tag with database values

查看:13
本文介绍了使用数据库值覆盖 Spring:message 标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Spring 来显示来自属性文件的消息.我希望能够覆盖 标记以使用基于登录用户的数据库中的值.如果此值不存在,我希望它像现在一样默认为属性文件中的当前值.

I am using Spring to display messages from a properties file. I would like to be able to override the <spring:message> tag to use a value from a database based on the logged in user. If this value is not present I would like it to default to the value currently in the properties file as it does now.

有人可以帮我处理这个代码吗?我已经阅读了 AbstractMessageSource,但我不清楚如何实现它.

Can someone help me with this code? I've read about AbstractMessageSource but I am unclear on how to implement it.

谢谢

推荐答案

您必须实现自定义消息源.它是一个扩展AbstractMessageSource 并实现抽象resolveCode(java.lang.String, java.util.Locale) 方法的类.在 SO 上几乎有相同的问题(这是解决方案Grails),但我认为从...开始是个好主意

You have to implement custom message source. It's a class that extends AbstractMessageSource and implements the abstract resolveCode(java.lang.String, java.util.Locale) method. There is almost same question on SO (it's solution for Grails), but I think it is good point to start from...

这篇关于使用数据库值覆盖 Spring:message 标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆