我是编程的新手,所以请在这里帮我一下。
我已配置Spring Security
为从数据库中以及在尝试使用以下帐户登录时获取用户详细信息:
身份验证失败,因为它始终将我重定向到home.jsp/OPS=999
我的登录页面。用户记录存在于数据库中,但我似乎无法登录。
这是我的安全配置xml文件。
<http auto-config="true">
<form-login login-page='/home.jsp?OPS=9999' default-target-url='/secure/user.jsp' always-use-default-target='true' />
<logout logout-success-url="/home.jsp" logout-url="/j_spring_security_logout" />
</http>
<authentication-provider>
<jdbc-user-service data-source-ref="Application.DataSource2" users-by-username-query="select USERNAME, PASSWORD from USER where lower(USERNAME) = lower(?)"/>
</authentication-provider>
由于登录不起作用,我目前没有身份验证/权限。身份验证失败的可能原因有哪些?数据库连接可以发挥作用吗?请帮帮我。
先感谢您!
意识到applicationContext-security xml文件中的按用户名查询的用户缺少启用的列,基本上spring security期望语句中有3列,而我缺少启用的列。
因此正确的sql语句应为:“从USER中选择USERNAME,PASSWORD,STATUS,其中lower(USERNAME)= lower(?)”
status列的类型为boolean。(1 =启用,0 =禁用)
希望它可以帮助某人:)
谢谢各位的帮助!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句