<%@tag pageEncoding="utf-8" %>
<%@tag body-content="empty"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
newMax.tag 파일작성
<%@attribute name="var" required="true" rtexprvalue="false" %>
<%@attribute name="num1" type="java.lang.Integer" %>
<%@attribute name="num2" type="java.lang.Integer" %>
<%@variable name-from-attribute="var" alias="maximum" variable-class="java.lang.Integer" scope="AT_END" %>
<%
int result;
if(num1 > num2) result = num1;
else result = num2;
%>
<c:set var="maximum" value="<%=result %>"/>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="util" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h3>최대값 구하기</h3>
<util:newMax var="max" num1="${param.num1}" num2="${param.num2}"/>
최대값 : ${max}
</body>
</html>
변수의 이름이 태그 파일 안에 고정되어 있다는 단점을 해결!
'JSP' 카테고리의 다른 글
SimpleTagSupport 클래스를 이용해서 태그 클래스 작성 (0) | 2013.03.22 |
---|---|
커스텀액션의 본체 안에서 변수 사용하기 (0) | 2013.03.22 |
변수를 지원하는 커스텀액션1 (0) | 2013.03.22 |
커스텀액션의 본체를 처리하는 태그파일 (0) | 2013.03.22 |
동적 애트리뷰트를 지원하는 태그파일 (0) | 2013.03.22 |