ふたりで

springboot+sitemesh 설정. 본문

Spring

springboot+sitemesh 설정.

graykang 2021. 12. 20. 16:51
728x90
반응형
SMALL

1. Meven dependency 설정.

		<!-- https://mvnrepository.com/artifact/org.sitemesh/sitemesh -->
		<dependency>
		    <groupId>org.sitemesh</groupId>
		    <artifactId>sitemesh</artifactId>
		    <version>3.0.1</version>
		</dependency>

2. sitemesh java 설정.

package com.graykang.config.sitemesh;

import org.sitemesh.builder.SiteMeshFilterBuilder;
import org.sitemesh.config.ConfigurableSiteMeshFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SiteMeshConfig extends ConfigurableSiteMeshFilter {

	@Bean 
	public FilterRegistrationBean<SiteMeshConfig> siteMeshFilter() {//빈등록 
		FilterRegistrationBean<SiteMeshConfig> filter = new FilterRegistrationBean<SiteMeshConfig>(); 
		filter.setFilter(new SiteMeshConfig()); 
		return filter; 
	}
	
	@Override
	protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
		builder 
		// Map decorators to path patterns.		
		.addDecoratorPath("/*", "/WEB-INF/decorators/default.jsp")
		.addDecoratorPath("**/popup/*", "/WEB-INF/decorators/popup.jsp")
		// Exclude path from decoration.
		.addExcludedPath("/login")
		.addExcludedPath("**/download/*")
		.addExcludedPath("**/ajax/*")
		.addExcludedPath("**/api/*")
		.setMimeTypes("text/html");		
	}
}
728x90
반응형
SMALL

3. sitemesh용 decorators 폴더 및 참조 파일 생성.

 

3. sitemesh용 default.jsp 설정.

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/decorators/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8" />
<title>기본레이아웃</title>
<%@ include file="/WEB-INF/decorators/include/head_css_js.jsp"%>
<style>

</style>
<script type="text/javascript">

</script>
<sitemesh:write property='head'/>
</head>
<body>
	<div id="app">
		<div class="wrap">
			<div class="side">
			</div>
			<div class="container container--side">
				<sitemesh:write property='body'/>
			</div>
			<div class="footer clearfix"></div>
		</div>
	</div>
</body>
</html>
728x90
반응형
LIST
Comments