本文介绍了Spring Security默认登录页面代码位于何处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用最简单的配置时, Spring Security 4 中生成的默认登录页面在哪里?

Where is the default login page generated in Spring Security 4 when you use the simplest of configurations?

<http>
...
    <form-login/>
</http>

我正在使用这个 Spring的基本示例Web应用程序安全性.

与这个问题几乎相同 Spring Security核心插件的默认登录页面在哪里?但对于Java

Is almost the same as this question Where is the default login page for the spring security core plugin? but for Java.

推荐答案

它是从此类 org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter 生成的:

private String generateLoginPageHtml(HttpServletRequest request, boolean loginError, boolean logoutSuccess) {
    String errorMsg = "none";

    [...]

    StringBuilder sb = new StringBuilder();

    sb.append("<html><head><title>Login Page</title></head>");

    if (formLoginEnabled) {
        sb.append("<body onload='document.f.").append(usernameParameter).append(".focus();'>\n");
    }

    [...]

这篇关于Spring Security默认登录页面代码位于何处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 01:08