jstl tag
jstl-1.2.jar
라이브러리 추가.
core fmk function
<body>
<h1>EL TEST</h1>
Select fruit : ${SelectFruit}
<h1>EL TEST</h1>
fruitVO : ${fv.name}
<h1>JSTL forEach TEST(Select Box)</h1>
<select id="fruitId" name="fruitName">
<c:forEach var="fruit" items="${fruitList }">
과일목록 : <option value="${fruit }" ${fruit==SelectFruit?'selected':'' }>${fruit}</option>
</c:forEach>
</select>
심어진 값(list)를item에 넣어주면 된다.
향상된 for문을 참고하자.
</body>
삼항연산도 가능하다.
${fruit==SelectFruit?'selected':'' }
----------------if 문--------------
<h1>JSTL IF TEST(Select Box)</h1>
<c:if test="${count >0 }">
<select id="fruitId" name="fruitName">
<c:forEach var="fruit" items="${fruitList }">
과일목록 : <option value="${fruit }" ${fruit==SelectFruit?'selected':'' }>${fruit}</option>
</c:forEach>
</select>
</c:if>
test는 항상 test를 써줘야 한다. 속성명이기 때문에.