Spring Security关于验证提示!
来源:互联网 发布:日本动画公司排行知乎 编辑:程序博客网 时间:2024/05/22 09:03
另外需要解决的是验证码问题,可以用filter方式解决,只有验证码通过了才去真的用spring security验证
------------------------------------------------------------------------------------
In Spring Security, when authentication is failed, following predefined error messages will be displayed :
Spring display : Bad credentials
In this article, we show you how to override above error message and display your custom error message. For example,
Spring display : Bad credentialsYou want override it with this message : Invalid username or password
Solution
Spring Security stored messages in “messages.properties” inside “spring-security-core.jar“, see figure below :
To override it, find which key generate what error message in spring security message.properties file, and redefine it with your own properties file.
1. Override Key and Message
Create a new properties file, put it on project classpath, and override the Spring’s “key” with your custom error message. In this case, just override “AbstractUserDetailsAuthenticationProvider.badCredentials
“.
File : mymessages.properties
AbstractUserDetailsAuthenticationProvider.badCredentials=Invalid username or password
2. Register ResourceBundleMessageSource
To load above properties file, define ResourceBundleMessageSource
in Spring bean configuration file.
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basenames"> <list> <value>mymessages</value> </list> </property> </bean>
Now, when authentication is failed, it will display your custom error message “Invalid username or password“, instead of the default “Bad credentials“.
- Spring Security关于验证提示!
- spring security验证流程
- spring security验证流程
- spring security 自定义验证
- spring security 权限验证
- spring security 登录验证
- spring Security 登录验证
- spring security 验证码
- spring security登录验证
- 关于spring security的权限验证有关问题
- Spring Security 3.1 登录验证
- spring security 登录验证 感想
- Spring Security inMemoryAuthentication 验证失败
- spring验证文件(spring-security.xml)
- 2. Spring Security 关于登录
- 关于spring security权限控制
- Spring Security-02-关于登录
- spring security登录失败的错误提示
- 使用Delphi声明C++带函数的结构体实战
- POJ 2828 Buy Tickets(神题!线段树or树状数组)
- How to catalog a db2 database
- 华为OJ 在字符串中找出连续最长的数字串
- DataSource Java 官方 DBCP
- Spring Security关于验证提示!
- 在Android中使用HandlerThread创建线程
- 堆 的取最值删除操作和插入操作
- Cocos2d-x对精灵的优化
- 如何将鼠标箭头设置成手型
- Redis,MemCached,MongoDB 概述
- 最美不过少年时,红尘走马,步步相随
- C++ Primer 7.33 练习编写成员函数
- c++ 时间类型详解 time_t