现在的位置: 首页 > 综合 > 正文

如何定制Acegi验证框架的验证错误信息

2012年12月04日 ⁄ 综合 ⁄ 共 1025字 ⁄ 字号 评论关闭
  • 编写资源文件,Acegi的DaoAuthenticationProvider使用了如下的资源Key
AbstractUserDetailsAuthenticationProvider.badCredentials=自定消息
AbstractUserDetailsAuthenticationProvider.onlySupports
=自定消息
AbstractUserDetailsAuthenticationProvider.locked
=自定消息 account was locked
AbstractUserDetailsAuthenticationProvider.disabled
=自定消息account was disabled
AbstractUserDetailsAuthenticationProvider.expired
=自定消息
AbstractUserDetailsAuthenticationProvider.credentialsExpired
=自定消息

  • 定义资源Bean
    <bean id="messageSource"
        class
="org.springframework.context.support.ResourceBundleMessageSource">
    
<property name="basename">
            
<value>资源文件(包名+资源文件名)</value>
        
</property>
    
</bean>

  • 将资源Bean注入到DaoAuthenticationProvider
1    <bean id="daoAuthenticationProvider"
2        class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
3        <property name="userDetailsService">
4            <ref local="inMemoryDaoImpl" />
5        </property>
6        <property name="messageSource">
7            <ref bean="messageSource" />
8        </property>
9    </bean>

抱歉!评论已关闭.