Implementing a custom login page
Implementing the login controller
@Controller
public class LoginLogoutController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "/login.do")
public void home() {
}
}
Adding the login JSP
there are 2 important elements of the login form that must be correct in order for the appropriate actions to occur:
The form action must match the action configured in the UsernamePasswordAuthenticationFilter servlet filter. By default, this form action is j_spring_security_check.
The form fields for username and password must match the servlet specifications. By default j_username and j_password are the form field names.
All this leaves us with a fairly simple JSP:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<jsp:include page="common/header.jsp">
<jsp:param name="pageTitle" value="Login"/>
</jsp:include>
<h1>Please Log In to Your Account</h1>
<p>
Please use the form below to log in to your account.
</p>
<form action="j_spring_security_check" method="post">
<label for="j_username">Login</label>:
<input id="j_username" name="j_username" size="20" maxlength="50"
type="text"/>
<br />
<label for="j_password">Password</label>:
<input id="j_password" name="j_password" size="20" maxlength="50"
type="password"/>
<br />
<input type="submit" value="Login"/>
</form>
<jsp:include page="common/footer.jsp"/>
Be aware that you must use a form POST, otherwise the login request will be rejected by the UsernamePasswordAuthenticationFilter.
Configuring Spring Security to use our Spring MVC login page
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/login.do" access="permitAll"/>
<intercept-url pattern="/*" access="hasRole('ROLE_USER')" />
<form-login login-page="/login.do" />
</http>
分享到:
相关推荐
1. **User Login**: Users can register and log in to the platform, creating a personalized experience for each customer. 2. **Product Query**: Users can search for clothing items based on various ...
In addition to the basic email services, the system likely includes features such as user registration, login authentication, inbox management, email composition and sending, as well as search ...
In conclusion, the Python-based community surveillance image splicing system combines the power of Python, MySQL, and B/S architecture to create a robust and user-friendly solution for enhancing ...
On the user side, the mini-program provides a user-friendly interface for registration and login, enabling parents to input and manage their child's information. They can access details about ...
the development of the "SSM Intangible Cultural Heritage Under Kashgar Tourism Website" demonstrates how technology can effectively serve the tourism industry, enhancing the visitor experience while ...
It replaces the default icons used in GTK applications with MacOSX-style icons, enhancing the overall consistency of the theme. Users can expect a wide range of icons to be changed, including those ...
4. **User Management**: The platform offers user registration and login functionality, allowing users to save their preferences, view order history, and manage their profiles. 5. **Payment ...
The use of JavaWeb-based systems, particularly with the SSH framework, offers a robust solution for streamlining hotel operations, improving customer experience, and maximizing profitability. ...
** This hack introduces interactive shells and demonstrates how they can be utilized for more dynamic and responsive command-line interactions, enhancing the user experience. 12. **Using Multiple ...
2. **Dynamic Data Display**: Implement dynamic content display based on user requests, enhancing user engagement and interactivity. 3. **Data Storage**: Learn to manage user and static data using both...
- **Additional APIs:** Geronimo supports additional APIs beyond the standard J2EE set, enhancing its capabilities. In addition to these core features, Geronimo offers extensions and plugins that ...