简体   繁体   English

可以通过弹簧安全性固定选项卡式表格

[英]Can secure tabbed form with spring security

I'm having trouble with secure form that have two tabs - Login/Register. 我在使用具有两个标签的安全表单时遇到麻烦-登录/注册。 Before adding the register tab it worked. 在添加注册选项卡之前,它可以工作。 I'm using spring security. 我正在使用Spring Security。 Is that even possible? 那有可能吗? Here is part of the code: jsp: Index.jsp 这是代码的一部分: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 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 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 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>

When I pressed the login button to submit the tabbed dialog it redirect me to loginfailed page. 当我按下登录按钮提交选项卡式对话框时,它将我重定向到登录失败页面。 I try to debut the CustomUserDetailsService class but its not executed. 我尝试启动CustomUserDetailsS​​ervice类,但未执行。 Can you please help me with this problem. 您能帮我解决这个问题吗? Thank is advice! 谢谢指教!

The includes <jsp:include page="login.jsp"/> and <jsp:include page="register.jsp"/> are nesting a form within a form - which is not valid HTML. 包括<jsp:include page="login.jsp"/><jsp:include page="register.jsp"/>将表单嵌套在表单中-这是无效的HTML。 The browser may not transmit what you expect - hence the login failed page. 浏览器可能无法传输您所期望的内容-因此登录页面失败。

You should remove the outer dialogForm declared in index.jsp and then edit login.jsp and change the action for the logingForm to be j_spring_security_check 您应该删除外dialogForm中声明index.jsp ,然后编辑login.jsp和更改操作的logingFormj_spring_security_check

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM