Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. The localhost page isn’t working
  2.  
  3. <http use-expressions="true">
  4. >
  5.  
  6. <intercept-url pattern="/**" access="isAuthenticated()"/> <!-- this means all URL in this app will be checked if user is authenticated -->
  7.  
  8. <form-login
  9. login-page="/login"
  10. default-target-url="/"
  11. authentication-failure-url="/login?error"
  12. username-parameter="username"
  13. password-parameter="password" />
  14.  
  15.  
  16. <logout logout-url="/logout" logout-success-url="/"/> <!-- the logout url we will use in JSP -->
  17. </http>
  18.  
  19. <!-- <!DOCTYPE html>
  20. <html>
  21. <head>
  22. <meta charset="ISO-8859-1">
  23. <title>Insert title here</title>
  24. </head>
  25. <body>
  26.  
  27. <div class="alert alert-danger" ng-show="error">
  28. There was a problem logging in. Please try again.
  29. </div>
  30.  
  31. <form role="form" ng-submit="login()">
  32. <div class="form-group">
  33. <label for="username">Username:</label> <input type="text"
  34. class="form-control" id="username" name="username" ng-model="credentials.username"/>
  35. </div>
  36. <div class="form-group">
  37. <label for="password">Password:</label> <input type="password"
  38. class="form-control" id="password" name="password" ng-model="credentials.password"/>
  39. </div>
  40. <button type="submit" class="btn btn-primary">Submit</button>
  41. </form>
  42.  
  43. </body>
  44. </html> -->
  45. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  46. <html>
  47. <head>
  48. <title>Custom Login Page</title>
  49. </head>
  50. <body onload='document.loginForm.j_username.focus();'>
  51. <h3>Custom Login Page</h3>
  52.  
  53. <%
  54.  
  55. String errorString = (String)request.getAttribute("error");
  56. if(errorString != null && errorString.trim().equals("true")){
  57. out.println("Incorrect login name or password. Please retry using correct login name and password.");
  58. }
  59. %>
  60.  
  61. <form name='loginForm' action="<c:url value='j_spring_security_check' />"
  62. method='POST'>
  63.  
  64. <table>
  65. <tr>
  66. <td>User:</td>
  67. <td><input type='text' name='j_username' value=''>
  68. </td>
  69. </tr>
  70. <tr>
  71. <td>Password:</td>
  72. <td><input type='password' name='j_password' />
  73. </td>
  74. </tr>
  75. <tr>
  76. <td><input name="submit" type="submit"
  77. value="submit" />
  78. </td>
  79. <td><input name="reset" type="reset" />
  80. </td>
  81. </tr>
  82. </table>
  83.  
  84. </form>
  85. </body>
  86. </html>
  87.  
  88. @RequestMapping(value = "/login", method = RequestMethod.GET)
  89. public ModelAndView login(ModelMap mode,
  90. @RequestParam(value = "error", required = false) String error,
  91. @RequestParam(value = "logout", required = false) String logout) {
  92. System.out.println("nt -------------");
  93. ModelAndView model = new ModelAndView("login");
  94.  
  95. if (error != null) {
  96. model.addObject("error", "Invalid username and password!");
  97. }
  98.  
  99. if (logout != null) {
  100. model.addObject("msg", "You've been logged out successfully.");
  101. }
  102. return model;
  103.  
  104. }
  105.  
  106. http://localhost:8080/SpringMvcSecurity/spring_security_login
  107.  
  108. http://localhost:8080/SpringMvcSecurity/login
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement