如何使用 Spring Security 自定义登录页面? [英] How to use Spring Security to custom login page?
本文介绍了如何使用 Spring Security 自定义登录页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用程序中使用 Spring Security,这里是对用户进行身份验证的安全部分,但登录页面由 Spring Security 提供:
@EnableWebSecurity公共类 SecurityConfig 扩展了 WebSecurityConfigurerAdapter {公共无效配置(HttpSecurity httpSecurity)抛出异常{http安全.authorizeRequests().antMatchers("/home*").hasRole("USER").和().formLogin();@自动连线public void configureGlobal(AuthenticationManagerBuilder auth) 抛出异常 {授权.inMemoryAuthentication().withUser("用户").password("密码").roles("用户")}}
我想使用下面的登录页面而不是 Spring 的登录页面:
login.html
:
<头><title>WebApp</title><meta charset='utf-8'/><script src="https://code.jquery.com/jquery-1.11.3.min.js"></script><link rel="stylesheet" type="text/css" href="css/bootstrap.css"/><link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"/><link rel="stylesheet" href="css/login.css"/>头部><身体><div class="登录页面"><img src='img/taxi_.jpg' style='width: 180px;左边距:自动;右边距:自动;显示:块;填充顶部:20px;填充底部:20px;'/><div class="heading"><center>仪表板</center>
<div class="form"><form action ="home.html" class="register-form"><input type="text" placeholder="name"/><input type="password" placeholder="password"/><input type="text" placeholder="email address"/><按钮>创建</按钮><p class="message">已经注册?<a href="#">登录</a></p></表单><form action="home.html" class="login-form"><input type="text" placeholder="username"/><input type="password" placeholder="password"/><button id="button_login">登录</button><p class="message">未注册?<a href="#">创建一个帐户</a></p></表单>