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. Is that even possible? Here is part of the code: 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>
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. 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. 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.