小编Ant*_*kov的帖子

Spring ReloadableResourceBundleMessageSource未找到消息

在我的应用程序中,我已经使用了ResourceBundleMessageSource

<bean id="messageSource"
    class="org.springframework.context.support.ResourceBundleMessageSource"
    p:basename="i18n/messages" />
Run Code Online (Sandbox Code Playgroud)

一切正常,但目前我想在我的应用程序中使用UTF-8编码,并将ResourceBundleMessageSource更改为ReloadableResourceBundleMessageSource

<bean id="messageSource"
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="i18n.messages" />
    <property name="defaultEncoding" value="UTF-8" />
    <property name="fileEncodings" value="UTF-8" />
</bean>
Run Code Online (Sandbox Code Playgroud)

不幸的是,在这次改变之后,我开始捕获NoSuchMessageException

org.springframework.context.NoSuchMessageException: No message found under code 'user.login.message.denied.title' for locale 'en'.
at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:135)
at com.project.common.utils.MessageSender.getI18nMessage(MessageSender.java:85)
at com.project.common.utils.MessageSender.showI18nErrorMessage(MessageSender.java:176)
at com.project.common.utils.MessageSender$$FastClassByCGLIB$$c025a19f.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.project.common.utils.MessageSender$$EnhancerByCGLIB$$d20cec5c.showI18nErrorMessage(<generated>)
at com.project.common.beans.user.LoginBean.login(LoginBean.java:93)
at com.project.common.beans.user.LoginBean$$FastClassByCGLIB$$c23dc7a1.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.project.common.beans.user.LoginBean$$EnhancerByCGLIB$$c7039dde.login(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native …
Run Code Online (Sandbox Code Playgroud)

spring utf-8 internationalization

6
推荐指数
1
解决办法
3965
查看次数

标签 统计

internationalization ×1

spring ×1

utf-8 ×1