jjzjj

MessageSource

全部标签

java - grails spock 测试失败,显示 'java.lang.IllegalArgumentException: ServletContext must not be null'

我在commandclass中有一个方法,它使用messageSource.getMessage(...),因为messageSource不会被注入(inject)到commandClass。我用defmessageSource=Holders.applicationContext.getBean("messageSource")在commandClass中。我的问题是在尝试编写单元测试这个方法时,@Beforevoidsetup(){Holders.applicationContext.getBean("messageSource")}void"testFunction"(){//i

java - 在 Spring MVC 框架中不使用 MessageSourceAware 访问 MessageSource 的方法

我有几个servlet旨在保存自己的消息源,但有一个静态函数使用此消息源作为备份,在正常情况下使用全局BDB检索本地化文本。我想知道是否有办法为调用此全局静态函数的servlet的上下文检索MessageSource?我无法在所有servlet中使用MessageSourceAware。我查看了Spring文档并找到了MessageSourceAware和@autowired属性。我不能使用注释,因为我使用的是spring2.0。感谢任何帮助。谢谢,部分 最佳答案 如果您的MessageSource是在您的WebApplicatio

java - Spring @Autowired messageSource 在 Controller 中工作但不在其他类中工作?

新更新:2010年12月31日晚上8:15非常肮脏的修复,但这是我暂时使messageSource工作的方式。我更改了我的Controller类以将“messageSource”传递给Message类,并且能够检索消息。请查看下面的类定义,让我知道您可能需要帮助的更多信息。非常感谢您提供的所有帮助。2010年12月31日下午3点由于无法成功通过注解配置messageSource,我尝试通过servlet-context.xml配置messageSource注入(inject)。我仍然将messageSource设为null。如果您需要任何更具体的信息,请告诉我,我会提供。提前感谢您的帮

java - 将 messageSource 移动到 applicationContext 会导致默认 messageSource 在 dispatcher-servlet 上下文中不可见

我有一个网络应用程序,我在其中定义了基本的dispatcher-servletweb.xml上下文并加载了applicationContext。我在dispatcher-servlet中定义了messageSource并将其注入(inject)到Controller中。我还在applicationContext中定义了我的服务,我可以将它们注入(inject)我的Controller(在dispatcher-servlet上下文中定义)。但是,当我将messageSource的定义移动到applicationContext以便某些服务可以解析消息时,dispatcher-servlet

java - 如何在 Spring 中处理多个文件和消息以实现国际化?

一些关于Spring国际化的文章讲述了如何交换通过语言环境等的消息,但我只找到了包含一些消息的用例..如何根据上下文组织和使用国际化文件?(验证、查看消息、默认消息、业务消息)我知道Spring使用模式(已定义消息文件的名称)+语言环境。例如:message_zh_CN。我怎样才能知道每个上下文的文件关于这种行为?我认为应该是:resources`--messages|--validation||--message_locale.properties|`--message_locale2.properties|--business||--message_locale.propertie

java - 从 messageSource 读取 unicode 给 Java 5 带来了问题

我用属性文件(例如:messages_en_US.properties、messages_de_DE.properties)制作了一个支持i18n的Spring(2.5.6)webapplication。这个.properties文件带有uni-codes。例如:busy=Besch\u00E4ftigt当从messageSource中读取busy关键字时,会给出以下结果:...privatestaticReloadableResourceBundleMessageSourcemessageSource;/***Getsamessagefromtheresources(.propert

java - 在 Spring Integration 中为 Redis 创建 MessageSource

我想配置InboundChannelAdapter以便它应该从redis队列中弹出消息并将其传递给基于Java的注释中的ServiceActivator(只是,更喜欢避免XML)。我从Spring文档中找到了代码:@Bean("someAdapter.source")@EndpointId("someAdapter")@InboundChannelAdapter(channel="channel3",poller=@Poller(fixedDelay="5000"))publicMessageSourcesource(){return()->{...};}但我在这里不明白的是,如何使用

java - 在 Spring Integration 中为 Redis 创建 MessageSource

我想配置InboundChannelAdapter以便它应该从redis队列中弹出消息并将其传递给基于Java的注释中的ServiceActivator(只是,更喜欢避免XML)。我从Spring文档中找到了代码:@Bean("someAdapter.source")@EndpointId("someAdapter")@InboundChannelAdapter(channel="channel3",poller=@Poller(fixedDelay="5000"))publicMessageSourcesource(){return()->{...};}但我在这里不明白的是,如何使用

Spring Boot yml ResourceBundle 文件

我正在使用Spring的MessageSource从类路径中的.properties文件中加载错误消息。我的属性尊重某个"template",例如{Object}.{field}.{unrespectedConstraint}示例:userRegistrationDto.password.Size=Lemotdepassedoitavoirauminimum6caractères.userRegistrationDto.email.ValidEmail=Mercidesaisiruneaddressemailvalide.在重构的情况下(例如更改类的名称),我必须在几个地方更改我的属性

Spring Boot yml ResourceBundle 文件

我正在使用Spring的MessageSource从类路径中的.properties文件中加载错误消息。我的属性尊重某个"template",例如{Object}.{field}.{unrespectedConstraint}示例:userRegistrationDto.password.Size=Lemotdepassedoitavoirauminimum6caractères.userRegistrationDto.email.ValidEmail=Mercidesaisiruneaddressemailvalide.在重构的情况下(例如更改类的名称),我必须在几个地方更改我的属性