Java 如何使用电子邮件创建Spring登录?

Java 如何使用电子邮件创建Spring登录?,java,spring,hibernate,spring-mvc,Java,Spring,Hibernate,Spring Mvc,我是春天的新手,从中学习。我被困在使用用户电子邮件的登录页面上。我能够使用jdbc用户服务使用用户名和密码创建登录。但现在我想用UserEmail更改登录名 用户名和密码登录的示例配置如下: <security:form-login login-page="/login" default-target-url="/product/productList/all" authentication-failure-url="/login?error" username-param

我是春天的新手,从中学习。我被困在使用用户电子邮件的登录页面上。我能够使用jdbc用户服务使用用户名和密码创建登录。但现在我想用UserEmail更改登录名

用户名和密码登录的示例配置如下:

<security:form-login login-page="/login"
    default-target-url="/product/productList/all" authentication-failure-url="/login?error"
    username-parameter="username" password-parameter="password" />
<security:logout logout-success-url="/login?logout" />
</security:http>
<security:authentication-manager>
    <security:authentication-provider>
        <security:jdbc-user-service data-source-ref="dataSource"
            authorities-by-username-query="SELECT username, authority FROM authorities WHERE username = ?"
            users-by-username-query="SELECT username, password, enabled FROM users WHERE username = ?" />
        <security:password-encoder ref="bcryptEncoder" />
    </security:authentication-provider>
</security:authentication-manager>
<form name="loginForm" action="<c:url value="/j_spring_security_check" />" method="post">

    <c:if test="${not empty error}">
        <div class="error" style="color: #ff0000;">${error}</div>
    </c:if>

    <div class="form-group">
        <label for="username">UserName : </label>
        <input type="text" id="username" name="username" class="form-control" />
    </div>
    <div class="form-group">
        <label for="password">Passwrod:</label>
        <input type="password" id="password" name="password" class="form-control" />
    </div>
    <input type="submit" value="Submit" class="btn btn-default">
    <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
登录表格如下:

<security:form-login login-page="/login"
    default-target-url="/product/productList/all" authentication-failure-url="/login?error"
    username-parameter="username" password-parameter="password" />
<security:logout logout-success-url="/login?logout" />
</security:http>
<security:authentication-manager>
    <security:authentication-provider>
        <security:jdbc-user-service data-source-ref="dataSource"
            authorities-by-username-query="SELECT username, authority FROM authorities WHERE username = ?"
            users-by-username-query="SELECT username, password, enabled FROM users WHERE username = ?" />
        <security:password-encoder ref="bcryptEncoder" />
    </security:authentication-provider>
</security:authentication-manager>
<form name="loginForm" action="<c:url value="/j_spring_security_check" />" method="post">

    <c:if test="${not empty error}">
        <div class="error" style="color: #ff0000;">${error}</div>
    </c:if>

    <div class="form-group">
        <label for="username">UserName : </label>
        <input type="text" id="username" name="username" class="form-control" />
    </div>
    <div class="form-group">
        <label for="password">Passwrod:</label>
        <input type="password" id="password" name="password" class="form-control" />
    </div>
    <input type="submit" value="Submit" class="btn btn-default">
    <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
如何更改以通过电子邮件验证用户,并同时绑定用户授权?请帮助我获得演示教程


多谢各位

您是否尝试更改SQL查询,以便在电子邮件地址而不是usrename上进行选择

例如:。。其中emailaddress而不是。。用户名在哪里