【问题标题】:spring security "param.error" in jsp page?jsp页面中的spring security“param.error”?
【发布时间】:2018-02-10 00:37:42
【问题描述】:

您能否解释一下param.errorparam.logout 变量在login.jsp 中的参数来自哪里?

我在 spring boot 中使用过 spring security

<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>

【问题讨论】:

    标签: spring jsp spring-security jstl


    【解决方案1】:

    您错误地使用了 JSTL。 “!=”将不起作用。如果你想做一个不等于条件,你必须使用“ne”关键字。像这样:

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

    但就您而言,您正在寻找的是:

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

    not empty 适用于空和空变量。

    回答您的问题... 如果不显示更多代码,就不可能知道您的变量来自哪里。您确定要在您的 servlet 中设置一些东西吗?

    【讨论】:

    • 感谢您的回答。能否请您提供哪些信息包含“参数”变量(属性)?
    • 在您的一个 servlet 中的某处,您正在设置对象类型的变量“param”。即 -> request.setAttribute("param", paramObject);
    • 您也可以通过 JSTL 将其设置在 .jsp 文件中。
    【解决方案2】:

    如果您在实现中使用 Spring Security 登录,那么这可能就是 param.errorparam.logout 的来源。

    详细解释请看-https://www.baeldung.com/registration-verify-user-by-email

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-18
      • 1970-01-01
      • 2014-01-19
      • 1970-01-01
      • 2011-11-13
      • 2014-07-21
      • 2017-01-12
      相关资源
      最近更新 更多