Skip to content

Instantly share code, notes, and snippets.

@sojw
Last active August 8, 2016 09:15
Show Gist options
  • Select an option

  • Save sojw/162917fa7499d52c029627c73c1a7fd6 to your computer and use it in GitHub Desktop.

Select an option

Save sojw/162917fa7499d52c029627c73c1a7fd6 to your computer and use it in GitHub Desktop.
Page Templating Using JSP Custom Tag
<%@ tag description="공통 레이아웃" pageEncoding="UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="meta_inner" fragment="true" %>
<%@ attribute name="head_inner" fragment="true" %>
<%@ attribute name="gnb_inner" fragment="true" %>
<%@ attribute name="body_inner" fragment="true" %>
<%@ attribute name="javascript" fragment="true" %>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex,nofollow" />
<jsp:invoke fragment="meta_inner" />
<title>${title}<c:if test="${empty title}">plug</c:if></title>
<jsp:include page="/WEB-INF/views/common/header.jsp" />
<jsp:invoke fragment="head_inner" />
</head>
<body>
<jsp:include page="/WEB-INF/views/common/gnb.jsp" />
<jsp:invoke fragment="gnb_inner" />
<jsp:invoke fragment="body_inner" />
<jsp:include page="/WEB-INF/views/common/footer.jsp" />
<jsp:invoke fragment="javascript" />
</body>
</html>
<%@ page language="java" pageEncoding="UTF-8"
contentType="text/html;charset=utf-8"%>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<t:main>
<jsp:attribute name="body_area">
<div>
<button onclick="hello();">Hello There</button>
</div>
</jsp:attribute>
<jsp:attribute name="javascript">
<script>
function hello() {
alert("Hello World");
}
</script>
</jsp:attribute>
</t:main>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment