Spring mvc spring-messageSource

Spring mvc spring-messageSource,spring-mvc,Spring Mvc,org.springframework.context.NoSuchMessageException:在区域设置“en_GB”的代码“user.username.empty”下未找到任何消息 目前我有以下代码: applicationContext.xml: <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" p:basena

org.springframework.context.NoSuchMessageException:在区域设置“en_GB”的代码“user.username.empty”下未找到任何消息

目前我有以下代码:

applicationContext.xml

<bean id="messageSource"
      class="org.springframework.context.support.ResourceBundleMessageSource"
      p:basename="messages" />

我试图做的是,如果用户尝试使用空白用户名在我的网站上注册时出现错误,则会给他们定义为
user.username.empty
。我的应用程序正在按预期工作,它正在查找错误
user.username.empty
,但是无论我将属性文件放在哪里,它都找不到它


我需要将属性文件放在哪个文件夹中?我需要如何命名它?

它必须命名为
messages.properties
,并且位于默认包的类路径中。当然,它必须包含这样一行:

user.username.empty=the message you want

您可以在同一位置使用名为
messages\u en\u GB.properties
的文件为
en\u GB
进行自定义。

它必须命名为
messages.properties
,并且位于默认包的类路径中。当然,它必须包含这样一行:

user.username.empty=the message you want

您可以在同一位置使用名为
messages\u en\u GB.properties
的文件为
en\u GB
进行自定义。

ahh,它必须位于默认类路径中。出于某种原因,我一直在读它应该在一个参考资料/消息文件夹或一些变化。谢谢啊,它必须在默认的类路径中。出于某种原因,我一直在读它应该在一个参考资料/消息文件夹或一些变化。谢谢