1 / 14

제 14 장 커스텀 태그

제 14 장 커스텀 태그. 2008 2 학기 인터넷비즈니스과 강 환수 교수. 커스텀 태그. 정의 반복적으로 사용되는 조건 , 반복 등의 제어흐름과 다양한 태그의 표현 부분을 하나의 새로운 태그로 정의하여 사용할 수 있는 XML 유형의 사용자 정의 태그. 커스텀 태그 생성. 커스텀 태그 만드는 방법. JSP 2.0 커스텀 태그 개요. 커스텀 태그 작성 절차 클래스 SimpleTagSupport. 문자열 출력 커스텀 태그 작성 절차. <myfirsttag:hello />

cardea
Télécharger la présentation

제 14 장 커스텀 태그

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 제 14 장커스텀태그 2008 2학기 인터넷비즈니스과 강 환수 교수

  2. 커스텀 태그 • 정의 • 반복적으로 사용되는 조건, 반복 등의 제어흐름과 • 다양한 태그의 표현 부분을 하나의 새로운 태그로 정의하여 사용할 수 있는 XML 유형의 사용자 정의 태그

  3. 커스텀 태그 생성 • 커스텀 태그 만드는 방법

  4. JSP 2.0 커스텀 태그 개요 • 커스텀 태그 작성 절차 • 클래스 SimpleTagSupport

  5. 문자열 출력 커스텀 태그 작성 절차 • <myfirsttag:hello /> • 태그 hello는 몸체는 없으며 문자열 “Hello Custom Tag!!!”를 출력 • 필요파일

  6. 커스텀 태그를 위한 자바 파일 작성 • HelloCustomTag.java

  7. TLD 파일과 JSP 파일 작성 • TLD 파일 • JSP 파일 <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>커스텀 태그</title> </head> <body> <%@ taglib uri="/WEB-INF/tld/HelloCustomTag.tld" prefix="myfirsttag" %> <H2>첫 커스텀 태그 예제 </H2> <center><HR> <myfirsttag:hello /> </center> </body> </html>

  8. 속성이 있는 커스텀 태그 만들기 • 테이블 출력 커스텀 태그 작성 절차

  9. 태그 파일 개요 • 태그 파일의 장점 • 자바에 익숙하지 않은 비개발자도 재사용이 가능한 커스텀 태그를 작성 • 프로그래머도 더 쉽게 작업 • HTML 코드와 같은 표현 부분이 많은 모듈을 태그로 만든다면 태그 처리기 방식보다 적합 • 태그 파일로 커스텀 태그 작성 절차

  10. 문자열 출력 커스텀 태그 작성 절차 • <mytag:hello /> • 태그 hello는 몸체는 없으며 문자열 “Hello Custom Tag using Tag File !!!”를 출력하는 태그

  11. 태그 파일로 만드는 구구단 커스텀 태그 • 구구단 커스텀 태그 작성 절차

  12. Multiplication.tag <%@ tag body-content="scriptless" pageEncoding="euc-kr" description="구구단(multiplication table) 출력태그"%> <%@ attribute name="begin" %> <%@ attribute name="end" %> <%@ attribute name="bgcolor" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:if test="${empty(begin)}" var="bool"> <c:set var="begin" value="2" /> </c:if> <c:if test="${empty(end)}" var="bool"> <c:set var="end" value="9" /> </c:if> <c:if test="${empty(begin)}" var="bool"> <c:set var="bgcolor" value="white" /> </c:if> <center> <H2><jsp:doBody /></H2> <table width=100% border=1 cellpadding=1 bgcolor="${bgcolor}" > <c:forEach var="i" begin="${begin}" end="${end}" > <tr align="center" > <c:forEach var="j" begin="1" end="9" > <td>${i} * ${j} = ${i * j}</td> </c:forEach> </tr> </c:forEach> </table> </center> <p><hr>

  13. JSP 프로그램과결과 <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>커스텀 태그</title> </head> <body> <h2> 태그 파일을 이용한 커스텀 태그 : multiplication </h2> <hr> <%@ taglib tagdir="/WEB-INF/tags" prefix="mytag" %> <mytag:multiplication> 구구단(2단에서 9단까지) </mytag:multiplication> <mytag:multiplication end="5" bgcolor="linen"> 구구단(2단에서 5단까지) </mytag:multiplication> <mytag:multiplication begin="3" end="7" bgcolor="yellow"> 구구단(3단에서 7단까지) </mytag:multiplication> </body> </html>

  14. Thank You ! www.dongyang.ac.kr

More Related