Spring Boot 集成 Spring Security 使用
创建时间:2018-05-19  访问量:8696  6  2

Spring Boot 集成 Spring Security 使用

<div class="container" style="width:95%;height:500px;margin-top:80px;">
	<div class="row">
		<div class="col-xs-8" style="padding:0;">
			<div style="height:500px;line-height:500px;text-align:center;font-size:100px;color:#eee;background:rgba(255,255,255,0.3)">
				资源共享社区
			</div>
		</div>
		<div class="col-xs-4" style="padding:0;">
			<div class="panel panel-default" style="height:500px;color:#333;">
				<div class="panel-body">
					<div style="margin-bottom: 20px;font-size:18px;">
						<a th:href="@{/study}"><img th:src="@{/app/images/logo.png}" style="margin-right: 30px;" /></a>
						<span style="color:red;font-size:20px;">会员</span>登录
					</div>
					<form name="login_form" th:action="@{/loginProcess}" method="post" autocomplete="off">
					  <div class="form-group">
					    <label for="loginName">登录名</label>
					    <input type="text" name="loginName" class="form-control" id="loginName" required="required" placeholder="请输入登录名" autofocus="autofocus" />
					  </div>
					  <div class="form-group">
					    <label for="password">密码</label>
					    <input type="password" name="password" class="form-control" id="password" required="required" placeholder="输入密码" />
					  </div>
					  <div class="form-group">
					    <label for="captcha" style="display:block;">验证码</label>
					    <input type="text" style="width:150px;display:inline;" name="captcha" class="form-control" id="captcha" required="required" placeholder="请输入验证码" />
					    <img id="imgCaptcha" alt="验证码" th:src="@{/auth/captcha}" style="height:32px;width:100px;margin-top:-2px;"/>
					    <a href="javascript:changeCaptcha();">看不清</a>
					  </div>
					  <div class="checkbox">
					    <label>
					      <input type="checkbox" id="rememberMe" name="rememberMe" />记住我一周
					    </label>
					  </div>
					  <input name="${_csrf.parameterName }" th:value="${_csrf.token }" type="hidden" />
					  <button type="submit" class="btn btn-success">登录</button>
					  <a th:href="@{/register}" style="margin-left:20px;">还没有帐号?</a>
					</form>
					<span style="margin-top:10px;">
						<div style="color:red;" th:if="${param.error }">用户名或密码错误</div>
						<div style="color:red;" th:if="${param.captcha }">验证码填写不正确</div>
						<div style="color:red;" th:if="${param.denied }">登录已过期</div>
						<div style="color:red;" th:if="${param.expired }">您可能在其它地方登录,本地自动退出</div>
					</span>
				</div>
			</div>
		</div>
	</div>
</div>

页面登录代码