본문 바로가기

JSP(Java Server Page)/JSTL

JSTL if문

<%@ page contentType="text/html; charset=UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page trimDirectiveWhitespaces="true" %>

<%

String cp = request.getContextPath();

request.setCharacterEncoding("utf-8");


%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSTL</title>

</head>

<body>


<form method="post"> <!-- action을 지정하지 않으면 자기자신이 받는다 -->

수 : <input type="text" name="num"/>

<input type="submit" value="전송">

</form>

<br/>

<c:if test="${not empty param.num }">

<c:if test="${param.num%2==0 }">

${param.num}은 짝수

</c:if>

<c:if test="${param.num%2!=0 }">

${param.num}은 홀수

</c:if>

</c:if>


</body>

</html>



'JSP(Java Server Page) > JSTL' 카테고리의 다른 글

JSTL fmf  (0) 2013.07.02
JSTL import  (0) 2013.07.02
JSTL varStatus  (0) 2013.07.02
JSTL forEach문  (0) 2013.07.02
JSTL when문  (0) 2013.07.02