반응형
import java.io.Serializable;
import java.util.List;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;
import com.commonlogic.menu.MenuVO;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Scope(value= WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
@Component("session")
public class SessionValue implements Serializable{
// private static final long serialVersionUID = 7508111457112535143L;
private List<MenuVO> menuTop;
private List<MenuVO> menuSub;
public String pageType;
public String getPageType() {
return this.pageType;
}
}
import java.io.IOException;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import com.commonlogic.menu.MenuDao;
import com.commonlogic.menu.MenuVO;
import com.commonlogic.value.SessionValue;
@Component
public class LoginSuccess implements AuthenticationSuccessHandler {
@Autowired
MenuDao menuDao;
@Inject
Provider<SessionValue> provider;
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
public LoginSuccess() {
}
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
List<MenuVO> menuTopList = menuDao.getMenuTopList();
List<MenuVO> menuSubList = menuDao.getMenuSubList();
SessionValue sessionValue = provider.get();
sessionValue.setMenuTop(menuTopList);
sessionValue.setMenuSub(menuSubList);
sessionValue.setPageType("I");
redirectStrategy.sendRedirect(request, response, "/main");
System.out.println("loginSuccess");
}
}
<c:choose>
<c:when test="${sessionScope['scopedTarget.session'].pageType == 'I' }">
<div class="gnb inside">
</c:when>
<c:otherwise>
<div class="gnb outside">
</c:otherwise>
</c:choose>
728x90
반응형
'웹 개발' 카테고리의 다른 글
[spring boot] war를 만들때 rootAbsolutePath가 null일 경우 (0) | 2019.09.23 |
---|---|
[spring security] Principal in JSP EL expression (0) | 2019.09.20 |
sencha grid tooltip (0) | 2019.08.24 |
javascript - string format ( {0} 과 같은 형태의 문자열을 replace ) (0) | 2019.08.24 |
javascript - comment documentation ( 주석을 문서화 ) (0) | 2019.08.24 |