웹 개발

[spring security] Principal in JSP EL expression

노루아부지 2019. 9. 20. 10:11
반응형

If you are using Maven, you need to add the taglibs library to your pom.xml.

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
    <version>3.1.3.RELEASE</version>
</dependency>

 

Then in jsp added:

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

And:

<sec:authentication property="principal" />

 

Spring Security:

<%@page import="com.UserVO"%>
<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.springframework.security.core.Authentication"%>

<%
	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
	UserVO userVo = (UserVO) auth.getPrincipal();
%>

var USER_CD = '<%=userVo.getUserCd() %>';

 

 

 

 

http://static.springsource.org/spring-security/site/docs/3.0.x/reference/taglibs.html

 

19. JSP Tag Libraries

Spring Security has its own taglib which provides basic support for accessing security information and applying security constraints in JSPs. This tag is used to determine whether its contents should be evaluated or not. In Spring Security 3.0, it can be u

docs.spring.io

 

728x90
반응형
loading