Intellij JSP - 페이지 이동 방법
less than 1 minute read
페이지 이동 방법
-
Forward
-
jsp:forward
<jsp:forward page="result.jsp">
<jsp:param name="id" value="qwer"/>
<jsp:param name="pw" value="1234"/>
</jsp:forward>
-
pageContext.forward(String s)
<% pageContext.forward("page.jsp"); %>
-
RequestDispatcher
<%
RequestDispatcher rd = request.getRequestDispatcher("page,jsp");
rd.forward(request,response);
%>
-
Forward의 파라미터 전달 방법
-
request값이 유지되기 때문에 request.setAttribute(String s, Object o) 메소드를 이용해 값을 전달
-
jsp:forward 태그에 <jsp:param name="" value=""/>
를 넣어 값을 전달
-
Redirect
-
response.sendRedirect(String s)
<%
response.sendRedirect("page.jsp");
%>
-
Html
-
<form action="page.jsp">
<label>ID : <input type="text" name="id"></label>
<label>Password : <input type="text" name="qw"></label>
<input type="submit" value="Submit">
</form>
-
a href=” “
<a href="page.jsp">Move Next Page</a>
-
location.href=” “
<input type="button" value="Move Next Page" onclick="location.href='page.jsp'">
-
JavaScript
-
location.href
<script>
location.href="page.jsp"
</script>
-
-
Leave a comment