Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring ResourceBunddleMessageSource未采用默认messages.properties文件_Java_Spring_Internationalization - Fatal编程技术网

Java Spring ResourceBunddleMessageSource未采用默认messages.properties文件

Java Spring ResourceBunddleMessageSource未采用默认messages.properties文件,java,spring,internationalization,Java,Spring,Internationalization,我正在使用SpringResourceBundleMessageSource进行国际化。在视图表单中,我使用fmt:message作为表单字段标签。在validator中,当字段值不正确时,我必须拒绝带有相应表单字段标签的字段&错误消息。 e、 g. 错误消息是:“abc的值不正确” 在验证器中,我不得不说- `errors.rejectValue("xyz", "error.message", new Object[] {getMessage("message.abc")})` 弹簧配置:

我正在使用SpringResourceBundleMessageSource进行国际化。在视图表单中,我使用
fmt:message
作为表单字段标签。在validator中,当字段值不正确时,我必须拒绝带有相应表单字段标签的字段&错误消息。 e、 g.

错误消息是:“abc的值不正确”

在验证器中,我不得不说-

`errors.rejectValue("xyz", "error.message", new Object[] {getMessage("message.abc")})`
弹簧配置:

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> 
 <property name="basename" value="MySource" /> 
</bean>

getMessage
中,我使用
MessageSourceAccesor
从资源文件中读取消息

我的资源文件名是
MySource.properties
,我的资源文件夹中没有其他特定于语言的文件,而且我能够在jsp视图中读取此文件中的标签,但是当我尝试从验证程序访问它时,我遇到异常(
NoSuchMessage
,适用于locale en中的abc)

简短的问题是,当没有提供语言资源文件时,如何指示spring资源使用默认属性文件(文件名不带后缀)来搜索消息


任何指针都有助于向前移动。

我假设您使用的是Spring MVC

您是否在应用程序上下文文件中配置了Spring资源包

示例

<beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">       
        <beans:property name="basename" value="classpath:messages" />
        <beans:property name="defaultEncoding" value="UTF-8" />
</beans:bean>

这个链接用一个演示详细解释了它


如果这有帮助的话,请给帖子打分。

我假设您使用的是Spring MVC

您是否在应用程序上下文文件中配置了Spring资源包

示例

<beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">       
        <beans:property name="basename" value="classpath:messages" />
        <beans:property name="defaultEncoding" value="UTF-8" />
</beans:bean>

这个链接用一个演示详细解释了它


如果这有帮助的话,请给这篇文章打分。

我也遇到了同样的问题。检查spring mvc的文档后,我的版本是4.1.1,ResourceBundleMessageSource将“basename”作为属性,而不是“basename

更新在SpringWeb应用程序上下文中配置的ResourceBundleMessageSourcebean的属性名,使其工作:D

<property name="basenames" value="messages"></property>


我还不能发布我的截图,因为我需要10分,而且我是这里的新手:D

我也遇到了同样的问题。检查spring mvc的文档后,我的版本是4.1.1,ResourceBundleMessageSource将“basename”作为属性,而不是“basename

更新在SpringWeb应用程序上下文中配置的ResourceBundleMessageSourcebean的属性名,使其工作:D

<property name="basenames" value="messages"></property>


我还不能发布我的截图,因为我需要10分,而且我是这里的新手:D

是的,我使用的是spring MVC&以下是我的配置-正如我提到的,它适用于视图,部分问题是通过validator。是的,我使用的是SpringMVC&以下是我的配置-正如我提到的,它适用于视图,部分问题是带有验证器。不,它还有
basename
属性
basename
将用于
String
数组:否,它还具有
basename
属性<代码>基名称将用于
字符串
数组: