簡體   English   中英

可以通過彈簧安全性固定選項卡式表格

[英]Can secure tabbed form with spring security

我在使用具有兩個標簽的安全表單時遇到麻煩-登錄/注冊。 在添加注冊選項卡之前,它可以工作。 我正在使用Spring Security。 那有可能嗎? 這是代碼的一部分:jsp:Index.jsp

<div id="dialog">
    <form id="dialogForm" action="j_spring_security_check" method="GET">
        <div id="tabs">
            <ul>
                <li><a href="#login">Login</a></li>
                <li><a href="#register">Register</a></li>
            </ul>
            <div id="login">
                <jsp:include page="login.jsp"/> 
            </div>
            <div id="register">
                <jsp:include page="register.jsp"/>  
            </div>
        </div>
    </form>
</div>  

login.jsp

    <form:form id="logingForm" action="login" method="GET"> 
    <div id="loginForm" class="ui-widget-content" >
          <table>
            <tr>
              <td align="right" width="100">User:</td>
                <td width="100"><input type="text" name="j_username"/></td>
             </tr>
             <tr>
                <td align="right" width="100">Password:</td>
                <td width="100"><input type="password" name="j_password" /></td>
             </tr>
          </table>
          <br>
          <input id="logInButton" type="submit" value="SignIn" />
    </div>
</form:form>

register.jsp

    <form:form id="mainRegForm" action="register" commandName="registration" method="GET">
    <table align="right" width="300" cellpadding="0">
            <tr>
                <td>User Name:<FONT color="red"><form:errors
                path="userName" /></FONT></td>
                <td><form:input path="userName" /></td>
            </tr>
            <tr>
                <td>Password:<FONT color="red"><form:errors
                path="password" /></FONT></td>
                <td><form:password path="password" /></td>
            </tr>
            <tr>
                <td>Confirm Password:<FONT color="red"><form:errors 
                path="confirmPassword" /></FONT></td>
                <td><form:password path="confirmPassword" /></td>
            </tr>
            <tr>
            <tr>
                <td>Email address:<FONT color="red"><form:errors path="email" /></FONT></td>
                <td><form:input path="email" /></td>
            </tr>
            <tr>
                <td>Age:<FONT color="red"><form:errors path="age" size="1" /></FONT></td>
                <td><form:select path="age" items="${ageList}"/></td>
            </tr>
            <tr>
                <td>Sex:<FONT color="red"><form:errors path="sex" size="1" /></FONT></td>
                <td><form:select path="sex" items="${mfList}"/></td>
            </tr>
            <tr>
                <td>Location:<FONT color="red"><form:errors path="location" size="1" /></FONT></td>
                <td><form:select path="location" items="${countryList}"/></td>
            </tr>
            <tr>
                <td><input type="submit" value="Register" onClick="submitRegister()"/></td>
            </tr>
    </table>
</form:form>    

spring-security.xml

<http auto-config="true">
    <form-login login-page="/index" default-target-url="/welcome"
        authentication-failure-url="/loginfailed" />
    <logout logout-success-url="/logout" />
</http>

<authentication-manager>
    <authentication-provider user-service-ref="customUserDetailsService">
    </authentication-provider>  
</authentication-manager>

<beans:bean id="customUserDetailsService" class="controllers.CustomUserDetailsService">
    <beans:property name="userDao" ref="userDao"/>
</beans:bean>

當我按下登錄按鈕提交選項卡式對話框時,它將我重定向到登錄失敗頁面。 我嘗試啟動CustomUserDetailsS​​ervice類,但未執行。 您能幫我解決這個問題嗎? 謝謝指教!

包括<jsp:include page="login.jsp"/><jsp:include page="register.jsp"/>將表單嵌套在表單中-這是無效的HTML。 瀏覽器可能無法傳輸您所期望的內容-因此登錄頁面失敗。

您應該刪除外dialogForm中聲明index.jsp ,然后編輯login.jsp和更改操作的logingFormj_spring_security_check

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM