비전공개미 개발노트
[JSP] jsp:include에 jsp:param값을 넘기기 본문
반응형
SMALL
info.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table border="1">
<tr>
<td>제품번호</td>
<td>P111</td>
</tr>
<tr>
<td>가격</td>
<td>10,000원</td>
</tr>
</table>
<jsp:include page="infoSub.jsp" flush="false">
//param type의 값 B를 넘긴다
<jsp:param name="type" value="B" />
</jsp:include>
</body>
</html>
infoSub.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String type = request.getParameter("type");
if(type == null){ return; }
%>
<br>
<table border="1" bgcolor="#00cccc">
<tr>
<td>타입</td>
<td><b><%=type %></b></td>
</tr>
<tr>
<td>특징</td>
<td>
<%
if(type.equals("A")){
%>강한 내구성<%
}else if(type.equals("B")){
%>뛰어난 대처 능력<%
}
%>
</td>
</tr>
</table>
</body>
</html>
[출력]
반응형
LIST
'프로그래밍 > JSP' 카테고리의 다른 글
[JSP] session값 지정하고 지정된 값 불러오기 (0) | 2022.10.12 |
---|---|
[JSP] jsp:useBean, jsp:setProperty, jsp:getProperty 사용하기 (0) | 2022.10.12 |
[JSP] get.Parameter값을 받아와서 페이지 바꾸기 (0) | 2022.10.12 |
[JSP] jsp:include를 이용해서 페이지 불러오기 (0) | 2022.10.12 |
[JSP] 세션 설정하기 (0) | 2022.10.11 |
Comments