'response.sendRedirect'에 해당되는 글 1건

  1. 2014.05.21 jsp:forward 와 request.sendRedirect()
Programming/jsp2014. 5. 21. 17:43
페이지를 자동으로 넘겨주는 방식으로 두가지가 존재하는데 가장 큰 차이점은
forward - 세션 유지 (기본객체 4가지를 재사용 함으로서 전부 유지됨)
response.sendRedirect(); - 세션 유지하지 않음(response 에서 하기 때문에)

[링크 : http://blog.daum.net/nakspite/7305451] 


기본적으로 아래의 방식으로 사용을 하지만
<jsp:forward page="index.mu" />

<%response.sendRedirect("index.mu");%>

스트럿츠에서 이렇게 액션으로 넘겨줄 경우 연결되지 않고 객체를 재사용하게 되므로,
index.jsp에서 다음의 내용만으로 사용해서 넘겨줄 경우 넘겨주는 페이지가 euc-kr을 쓸경우 인코딩이 깨지게 된다.
<%@ taglib prefix="s" uri="/struts-tags" %>
<s:action name="index" executeResult="true" />

그러므로 넘겨줄 페이지의 인코딩을 넣어서 주거나 reDirect를 쓰는게 옳을 것으로 생각된다.
<%@ page contentType="text/html; charset=euc-kr"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<s:action name="index" executeResult="true" />

[링크 : http://stackoverflow.com/questions/16056166/jspforward-tag-forwards-to-struts-2-action

Posted by 구차니