Search code examples
springjspspring-securityjstl

spring security "param.error" in jsp page?


Could you please explain where are the parameters param.error and param.logout variables come from in login.jsp?

I have used spring security with spring boot

<c:if test="${param.error != null}">
   <div class="alert alert-danger">
       Invalid username and password.
   </div>
</c:if>

<c:if test="${param.logout != null}">
   <div class="alert alert-success">
       You have been logged out successfully.
   </div>
</c:if>

Solution

  • You're using JSTL incorrectly. "!=" will not work. If you want to do a not equals condition you have to use the "ne" keyword. Like so:

     <c:if test="${param.x ne param.y}">
    

    But in your case, what you're looking for is this:

    <c:if test="${not empty param.logout}">
    
    <c:if test="${not empty param.error}">
    

    not empty works on empty and null variables.

    To answer your question... Without showing any more code, it's not possible to know where your variables come from. Surely you are setting something in your servlets?