Iām stuck, maybe I missed something in the documents or made a small mistake.
Spring Security 3.0.5 was included in my Spring MVC 3.0.5 application. AcceptHeaderLocaleResolver is used for local discovery, and localization is working fine except for security error messages.
I copied messages.properties from the Spring Security Pack and renamed and added a bean (ResourceBundleMessageSource) to the existing "messageSource" list of values.
As mentioned earlier, all texts and messages are correctly localized, except for protective seams, for using hard-coded English messages.
Any ideas how to solve this?
UPDATE:
My xy-servlet.xml contains:
...
<mvc:resources mapping="/resources/**" location="/resources/" />
...
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>defaultMessages</value>
<value>securityMessages</value>
</list>
</property>
</bean>
and files
defaultMessages.propertiesdefaultMessages_en.propertiesdefaultMessages_de.propertiesdefaultMessages_sl.properties
and
securityMessages.propertiessecurityMessages_en.propertiessecurityMessages_de.propertiessecurityMessages_sl.properties
but it defaultMessagesworks fine. securityMessagesno. I made small changes to all the securityMessagesfiles, but they are ignored and hardcoded English messages are displayed.
UPDATE v2:
My dispatcher-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<context:component-scan base-package="com.example.sampleapp1" />
<context:annotation-config />
<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/resources/" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/views/" p:suffix=".jsp" />
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>defaultMessages</value>
<value>securityMessages</value>
<value>org/springframework/security/messages_de</value>
</list>
</property>
</bean>
<bean id="myPMF" class="org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean">
<property name="persistenceManagerFactoryName" value="transactions-optional"/>
</bean>
</beans>
source
share