문제상황 :
controller의 model 객체 안에 필요한 값이 없었으나,(location)
view로 넘어가며, model에 값들이 주입되어 있다.
원인:
이는 인터셉터에서(SponsorSessionCheckIntercepter)
postHandle을 통해 model에 값을 주입 해주고 있었기 때문
@Override
public void postHandle(HttpServletRequest request,
HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
Principal principal = request.getUserPrincipal();
Authentication authentication = (Authentication) principal;
if (Pattern.matches(ACCESS_SPONSOR_URL, request.getRequestURI())) {
User user = (User) authentication.getPrincipal();
if (user.getSponsorKey() != null && modelAndView != null && !StringUtils.isEmpty(user.getSponsorName())) {
modelAndView
.addObject("sponsorId", user.getSponsorId() != null ? user.getSponsorId().toLowerCase() : "");
modelAndView.addObject("sponsorName", user.getSponsorName() != null ? user.getSponsorName()
.toLowerCase() : "");
modelAndView.addObject("timezone", user.getTimezone() != null ? user.getTimezone() : "UTC+9");
modelAndView.addObject("location", user.getLocation() != null ? user.getLocation() : "Asia/Seoul");
modelAndView.addObject("existLogoFile", user.isExistLogoFile());
} else if (StringUtils.isEmpty(user.getSponsorName()) && modelAndView != null) {
modelAndView.setViewName(String.format("redirect:%s", domainURL));
}
}
|
'개발 > Spring' 카테고리의 다른 글
[Spring] 스프링03 (1) | 2022.12.27 |
---|---|
[Spring] 스프링 02 (1) | 2022.12.27 |
[Spring] 스프링 (0) | 2022.12.27 |