Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The localhost page isn’t working
- <http use-expressions="true">
- >
- <intercept-url pattern="/**" access="isAuthenticated()"/> <!-- this means all URL in this app will be checked if user is authenticated -->
- <form-login
- login-page="/login"
- default-target-url="/"
- authentication-failure-url="/login?error"
- username-parameter="username"
- password-parameter="password" />
- <logout logout-url="/logout" logout-success-url="/"/> <!-- the logout url we will use in JSP -->
- </http>
- <!-- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="ISO-8859-1">
- <title>Insert title here</title>
- </head>
- <body>
- <div class="alert alert-danger" ng-show="error">
- There was a problem logging in. Please try again.
- </div>
- <form role="form" ng-submit="login()">
- <div class="form-group">
- <label for="username">Username:</label> <input type="text"
- class="form-control" id="username" name="username" ng-model="credentials.username"/>
- </div>
- <div class="form-group">
- <label for="password">Password:</label> <input type="password"
- class="form-control" id="password" name="password" ng-model="credentials.password"/>
- </div>
- <button type="submit" class="btn btn-primary">Submit</button>
- </form>
- </body>
- </html> -->
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
- <html>
- <head>
- <title>Custom Login Page</title>
- </head>
- <body onload='document.loginForm.j_username.focus();'>
- <h3>Custom Login Page</h3>
- <%
- String errorString = (String)request.getAttribute("error");
- if(errorString != null && errorString.trim().equals("true")){
- out.println("Incorrect login name or password. Please retry using correct login name and password.");
- }
- %>
- <form name='loginForm' action="<c:url value='j_spring_security_check' />"
- method='POST'>
- <table>
- <tr>
- <td>User:</td>
- <td><input type='text' name='j_username' value=''>
- </td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><input type='password' name='j_password' />
- </td>
- </tr>
- <tr>
- <td><input name="submit" type="submit"
- value="submit" />
- </td>
- <td><input name="reset" type="reset" />
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>
- @RequestMapping(value = "/login", method = RequestMethod.GET)
- public ModelAndView login(ModelMap mode,
- @RequestParam(value = "error", required = false) String error,
- @RequestParam(value = "logout", required = false) String logout) {
- System.out.println("nt -------------");
- ModelAndView model = new ModelAndView("login");
- if (error != null) {
- model.addObject("error", "Invalid username and password!");
- }
- if (logout != null) {
- model.addObject("msg", "You've been logged out successfully.");
- }
- return model;
- }
- http://localhost:8080/SpringMvcSecurity/spring_security_login
- http://localhost:8080/SpringMvcSecurity/login
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement