1

我正在尝试使用 Seam 的身份管理在 Seam 2 中创建登录。我将 mysql 5.1 用于 RDB。我已经创建了一个登录页面并修改components.xml了身份验证。但问题就在这里。当我从 UI 单击登录按钮时,它会引发登录失败。但我可以从日志中观察到它查询数据库,如下所示。

10:27:40,670 INFO  [STDOUT] Hibernate: 
10:27:40,670 INFO  [STDOUT]     select
10:27:40,671 INFO  [STDOUT]         user0_.id as id10_,
10:27:40,671 INFO  [STDOUT]         user0_.email as email10_,
10:27:40,671 INFO  [STDOUT]         user0_.password as password10_,
10:27:40,671 INFO  [STDOUT]         user0_.userName as userName10_,
10:27:40,671 INFO  [STDOUT]         user0_.version as version10_ 
10:27:40,671 INFO  [STDOUT]     from
10:27:40,671 INFO  [STDOUT]         User user0_ 
10:27:40,671 INFO  [STDOUT]     where
10:27:40,672 INFO  [STDOUT]         user0_.userName=? limit ?

但是无论是无法匹配userName&password还是其他原因,登录都不成功。这是我的login.xhtml页面

<h:form id="loginForm">

            <rich:panel>
                <f:facet name="header">Login</f:facet>

                <p>Please login here</p>

                <div class="dialog">
                    <h:panelGrid columns="2" rowClasses="prop"
                        columnClasses="name,value">
                        <h:outputLabel for="username">Username</h:outputLabel>
                        <h:inputText id="username" value="#{credentials.username}" />
                        <h:outputLabel for="password">Password</h:outputLabel>
                        <h:inputSecret id="password" value="#{credentials.password}" />
                        <h:outputLabel for="rememberMe">Remember me</h:outputLabel>
                        <h:selectBooleanCheckbox id="rememberMe"
                            value="#{rememberMe.enabled}" />
                    </h:panelGrid>
                </div>

            </rich:panel>

            <div class="actionButtons">
                <h:commandButton id="submitBtn" value="Login"
                    action="#{identity.login()}" />
            </div>

        </h:form>

这是我的相关部分component.xml

<!-- USER AND ROLE -->
<security:jpa-identity-store role-class="com.galaksiya.kobar.entity.Role"
    user-class="com.galaksiya.kobar.entity.User" />
<!-- IDENTITY STORE AND ROLE STORE -->
<security:identity-manager identity-store="#{jpaIdentityStore}"
    role-identity-store="#{jpaIdentityStore}" />

我按照此处记录的注释RoleUser类。但我不知道为什么我的登录失败。

任何帮助,将不胜感激。谢谢。

4

0 回答 0