본문 바로가기

JSP, Servlet/JSP, Servlet 기초

[JSP] fmt태그 실습하기

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		java.util.List<String> seasonList = new java.util.ArrayList<String>();
	seasonList.add("봄");
	seasonList.add("여름");
	seasonList.add("가을");
	seasonList.add("겨울");
	pageContext.setAttribute("list", seasonList);
	%>
	<select name="selectSeason">
		<c:forEach var="season" items="${list }" varStatus="status">
			<option value="${season }">${season }</option>
		</c:forEach>
	</select>

	<hr>

	<c:forEach var="season" items="${list }" varStatus="status">
${season }
</c:forEach>
</body>
</html>

 

 

728x90
반응형