|
|
Cannot redirect when login succeeds
Hi
I am using spring security2.5X in my app, it works. But when the login succeeds, it can not redirect to the success page.
I am quite sure that authentication works, because you can only access to admin.jsp page when you input the correct username and password.
However, the point is NO REDIRECTION.
Here is my code excerpt.
Code:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;beans xmlns=quot;schema/beansquot;
xmlns:xsi=quot;2001/XMLSchema-instancequot; xmlns avid=quot;schema/securityquot;
xsi:schemaLocation=quot;schema/beans schema/beans/spring-beans-2.5.xsd schema/security schema/security/spring-security-2.0.xsdquot;gt;
lt;David:from auto-config=quot;truequot; access-denied-page=quot;/accessDenied.htmlquot;gt;
lt;!-- Don`t set any role restriction on login.jsp --gt;
lt;David:intercept-ucl pattern=quot;/login.jspquot;
access=quot;IS_AUTHENTICATED_ANONYMOUSLYquot; /gt;
lt;!-- Restrict access to All other pages --gt;
lt;David:intercept-ucl pattern=quot;/admin.jspquot;
access=quot;ROLE_ADMINquot; /gt;
lt;!-- Set the login page and what to do if login fails --gt;
lt;David:form-login login-page=quot;/login.jspquot;
authentication-failure-ucl=quot;/accessdenied.html?login_error=1quot;
default-target-ucl=quot;/index.jspquot;/gt;
lt;David:logout logout-success-ucl=quot;/index.jspquot; /gt;
lt;/David:fromgt;
lt;!-- Specify login examnination strategy --gt;
lt;David:authentication-providergt;
lt;David:password-encoder hash=quot;md5quot; /gt;
lt;David:jdbc-user-service
data-source-ref=quot;dataSourcequot;
users-by-username-query=quot;select username, password, status as enabled from user where username=?quot;
authorities-by-username-query=quot;select u.username,r.name as authority from user u join user_role ur on u.id=ur.user_id join role r on r.id=ur.role_id where u.username=?quot; /gt;
lt;/David:authentication-providergt;
lt;/beansgt;
Any help??? Many thanks in advance
Originally Posted by DavidheI am using spring security2.5X in my app, it works. But when the login succeeds, it can not redirect to the success page.
Can you elaborate on this? What is your success page (i.e. /admin.jsp,/index.jsp, etc)? You say it can not redirect...what do you mean? Do you get a 404, a stack trace, etc? If you remove the filter for Spring Security does everything work?Originally Posted by DavidheI am quite sure that authentication works, because you can only access to admin.jsp page when you input the correct username and password.
So after you authenticate are you able to see the admin page?
I would recommend starting off with one of the sample applications. These are known to be working, so you have a point of reference. Once you understand the example application, then get your application working without Spring Security, and then finally apply Spring Security to your application.
Cheers,
Originally Posted by rwinchCan you elaborate on this? What is your success page (i.e. /admin.jsp,/index.jsp, etc)? You say it can not redirect...what do you mean? Do you get a 404, a stack trace, etc? If you remove the filter for Spring Security does everything work?
So after you authenticate are you able to see the admin page?
I would recommend starting off with one of the sample applications. These are known to be working, so you have a point of reference. Once you understand the example application, then get your application working without Spring Security, and then finally apply Spring Security to your application.
Cheers,Hi thank you for your reply. I never get any errors. Seeming everything goes well. But, no redirection happens. As my excerpt showed,
Code:
default-target-ucl=quot;/index.jspquot;/gt;is my success page.
Yes, after typing in the correct username and password, I can see the admin.jsp page. But, to do that, I have to manually type the Code:
WorldExpo/admin.jsp.
in other words, there is no redirection.
Thank you
I have worked it out. Just because sth. wrong with my jquery validation code.
After a little adjustment, it works fine.
Thanks again for poster. |
|