Я застрял, возможно, что-то пропустил в документации или сделал небольшую ошибку.
Spring Security 3.0.5 был интегрирован в мое приложение Spring MVC 3.0.5. AcceptHeaderLocaleResolver используется для определения локали, и локализация работает нормально, за исключением сообщений об ошибках безопасности.
Я скопировал messages.properties из пакета безопасности Spring, переименовал и добавил к существующему bean-компоненту «messageSource» (ResourceBundleMessageSource) список значений.
Как было сказано ранее, все тексты и сообщения локализованы правильно, за исключением Защитные швы для использования жестко закодированных сообщений на английском языке.
Есть идеи, как решить эту проблему?
ОБНОВЛЕНИЕ:
Мой xy-servlet.xml содержит:
...
<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>
и файлы
defaultMessages.properties
defaultMessages_en. свойства
defaultMessages_de.properties
defaultMessages_sl.properties
и
securityMessages.properties
securityMessages_en.properties
securityMessages_de.properties
securityMessages_sl.properties [128523] но [по умолчанию] 11108524] работает нормально. securityMessages
- нет.Я внес небольшие изменения во все файлы securityMessages
, но они игнорируются и отображаются жестко закодированные английские сообщения.
ОБНОВЛЕНИЕ 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/>
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources/ directory -->
<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>
<!-- Persistence -->
<bean id="myPMF" class="org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean">
<property name="persistenceManagerFactoryName" value="transactions-optional"/>
</bean>
<!-- Form Validator -->
</beans>