<!-- 시큐리티 태그 라이브러리 -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
다음과 같이 dependency를 추가해준다.
Spring Security를 사용하면 웹 앱을 실행하면 어느 곳을 접근해도 로그인 화면이 나온다.
들어가기 위해서는 콘솔에 생성된 비밀번호를 입력해야한다.
로그인을 하면 자동으로 세션이 생성된다.
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!--JSP 상단에 위 taglib을 적어준다.-->
<sec:authorize access="isAuthenticated()">
<script>
alert("로그인 인증 완료");
</script>
</sec:authorize>
<!-- 이처럼 인증 완료시 확인 메서드를 설정하면 인증 직후 alert창이 뜬다.-->
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authorize access="isAuthenticated()">
<sec:authentication property="principal" var="변수"/>
</sec:authorize>
<!--위와 같이 설정 후 변수를 지정하면 로그인에 사용된
사용자 정보가 입력된다.-->