게시판을 만들고 있는데
로그인이 되어있지않은 비회원자가 index 페이지에 있는 '글쓰기' 를 눌렀을때 로그인 페이지로 넘어가게되고, 여기서 로그인을 했을때 index페이지(이전페이지) 로 되돌아가는것이 아닌 글쓰기 페이지로 넘어가게끔 하고싶습니다.현재 핸들러로 이전페이지로 가는건 아래처럼 해놓긴 했는데 어떤 방식으로 구현할 수 있나요?
public class SuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
public SuccessHandler(String defaultTargetUrl) {
setDefaultTargetUrl(defaultTargetUrl);
}
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws ServletException, IOException {
HttpSession session = request.getSession();
if (session != null) {
String redirectUrl = (String) session.getAttribute("prevPage");
System.out.println("redirectUrl="+redirectUrl);
if (redirectUrl != null) {
session.removeAttribute("prevPage");
getRedirectStrategy().sendRedirect(request, response, redirectUrl);
} else {
super.onAuthenticationSuccess(request, response, authentication);
}
} else {
super.onAuthenticationSuccess(request, response, authentication);
}
}
}