94 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
vishnupriya
10 years ago

hi i have tried your example i am getting no handler for j_spring_security_check…

rajesh
7 years ago
Reply to  vishnupriya

no need j_spring_security_check interceptor internally provided by spring security. make sure about your username and password input field has the same parameter as defined in SecurityConfig class .

MUKESH THAKUR
9 years ago
Reply to  vishnupriya

hi
vishnupriya

how to create login page in spring mvc where 10 username or password is hardcoded using map interface

please solve this problem

Rishi
6 years ago

can you share password less authentication using Spring MVC and Spring Security

El Kn
8 years ago

Where is the documentation for the XML descriptors?

harry potter
8 years ago

Hi, How r u getting the user context in the above example ?

ABC
8 years ago

No program run here. Are you fooling people?

Mahesh S
9 years ago

Hi.. I have done a social app what type of security I can give for that

Rocky
10 years ago

Mkyong thank you for the tutorial, I gave you +20 rep. in stackoverflow, now your reputation moves up to 1011 😉

Leang Socheat
10 years ago

what is a *?. for example admin**, what does it mean?

Htet Naing Aung
5 years ago
Reply to  Leang Socheat
  • meaning of * is other character can add behind of “admin”
  • Example: /adminLogin
giorgio amato
10 years ago

Please note that like this it doesn’t work, because you need also processing url in the spring-security.xml, like the following:

with this you will get correct feedback information about login attempt

Yasin Kasap
10 years ago

Hi Mknyong,

I wanna call you “sensei”

Thanks

agung wijaya
10 years ago

it appears that is not supported in spring security 3.1. how do I enable csrf in that version?

Polyk
10 years ago

In the login method of the controller, the user is redirected again to the login page even if there is no error —> loop !
How can it go back to the admin page ?

Polyk
10 years ago
Reply to  Polyk

Solved . I haven’t used the wright username-parameter

Anshul
11 years ago

Hi.. The project s awesome but whenever i’m adding filter tags to my web.xml it is giving me resource unavailable error after that. can anyone tell me why it is happening??

Prasanna
11 years ago

I Am getting now this error:

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

Teejay
11 years ago

Hi, Can I use Spring MVC Form Tags (eg, ) with Spring Security functionality together? I noticed everyone uses standard html form tags. If it’s possible, what would be the parts to care about? Thanks a lot in advance!!

Jack Parker
11 years ago

If I want to implement this into an existing project. Let’s say without the welcome page redirect, and the page goes straight to the login, and then to the index. jsp page for my project how would I go about that?

I’ve tried setting it up according to the instructions here, and on another site, but I keep getting a 404 error anytime I make any sort of change to the web.xml

karthi
11 years ago

Hi
This post is awesome. I uploaded ur project by choosing Import-> Existing Maven Project . What shld I choose if i do it by my own. ie whether to choose File-> New ( A Maven Project or a Spring Project or Simple Spring Maven or Simple Spring Web Maven

Nicki
11 years ago

Hi ,

My project name is Formhandling .i tried to use spring security .i am facing below error:
WARNING: No mapping found for HTTP request with URI [/FormHandling/kik] in DispatcherServlet with name ‘FormHandling’
Jan 19, 2015 11:17:07 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/FormHandling/] in DispatcherServlet with name ‘FormHandling’
plzz hlp

konstantinh
11 years ago

mkyong that is a good post , however could you please elaborate on something i.e.your hello controller has only get methods, where is the HTTP post beeing done? One thing i do not understand is why this constelation is working at all, if the HTTP POST where the username and the password are supposed to be recieveid is not beeing processed from this code, or is there any magic behind this? I would really appreciate any feedback regarding this question. The reason i am asking this question is because i would like to use your example but work on my custome login controller, for example what would your login controller look like if you had not just user name and password but additional parameters such as certificate , or what if you were about to authenticate SRP (Secure Remote Password protocol) application

Rajesh
11 years ago

i am getting two errors to run the program.

1.java.lang.NoSuchMethodError: org.springframework.web.context.support.XmlWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;

2.java.lang.IllegalStateException: LifecycleProcessor not initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Sat Sep 27 17:45:41 IST 2014]; root of context hierarchy

h47
11 years ago

Hi Mkyong : am rookie to springFw i got required output as i coded as in above example of yours; But a Big ” ” ” ” Disappointing ” factor is that after i logout and i click on browser ” Back button ” then it shows previous admin page, why is this happing same problem is occurs and not solved when i write Basic JSP AND SERVLET web app, any suggestions mky. thank for this tutorial…

Sonu Kumar
11 years ago

Hello “Mr. Mkyong” all is good. but could you please provide the .xml files so that the freshers are also can understand. if it’s possible then please provide.

Sonu Kumar
11 years ago

in STS, when press login button…
WARN : org.springframework.web.servlet.PageNotFound – No mapping found for HTTP request with URI [/lead/] in DispatcherServlet with name ‘appServlet’

Surendran Duraisamy
12 years ago

Following are the problems I faced. Hope this would be helpful for other.

1. class loader issue.
Solution: include spring jar in the lib folder of your war
2. EL expressions not evaluated
Solution: use following tag for

akshay
12 years ago

Sir,
Can you please show me how save and retrieve an image from sql in spring.

Roberto Massimi
12 years ago

Nice tutorial.
It’s work for me but I don’t load a static resource.
I’ve copied header.png in srcmainwebapprisorse.
in hello.jsp I put
<img src='’ alt=”” id=”logo”/>
but i received this error:
Failed to load resource: the server responded with a status of 404 (Not Found)
How to load static resource? I read from web, ma I don’t understand the solution.
You can help me?

*sorry for a little my english
Roberto

shggy
12 years ago

Nice tutorial
But I am getting problem,
I am getting login page twice and then it gets logged in
Why?

lolo
12 years ago

How can we do to Junit test for this

1-login-page=”/login” – The login form will be “/login”
2-default-target-url=”/welcome” – If authentication success, forward to “/welcome”
3-authentication-failure-url=”/loginfailed” – If authentication failed, forward to “/loginfailed”
4-logout-success-url=”/logout” – If logout , forward to “/logout”

Manas
12 years ago

Good Post but I am weak in Java
Here find login form in PHP
http://www.discussdesk.com/download-login-form-in-PHP-and-mysql.htm

kon
12 years ago
Reply to  Manas

for what?

Vicky
12 years ago

One strange behavior that I noticed is, once you are at url http://localhost:8080/SpringMVC/login

and provide the incorrect url then url should be changed to http://localhost:8080/SpringMVC/loginfailed but it is not! It is at /login only. What can be the reason?

errikos
12 years ago
Reply to  Vicky

Are you sure you have the @RequestMapping annotation in the loginError method?