* 테스트 환경
- Windows 7 64bit
- STS 3.2.0 ( VMware vFabric tc Server Developer Edition v2.7 )
- thymeleaf 2.0.17
Spring MVC + Thymeleaf 적용 |
STS를 이용하여 Spring MVC + Thymeleaf 적용하기
1. Spring MVC 프로젝트 생성
2. pom.xml
### xml
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.0.17</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring3</artifactId>
<version>2.0.17</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-testing</artifactId>
<version>2.0.3</version>
</dependency>
3. servlet-context.xml
### xml
<!-- **************************************************************** -->
<!-- THYMELEAF-SPECIFIC ARTIFACTS -->
<!-- TemplateResolver <- TemplateEngine <- ViewResolver -->
<!-- **************************************************************** -->
<beans:bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<beans:property name="prefix" value="/WEB-INF/templates/" />
<beans:property name="suffix" value=".html" />
<beans:property name="templateMode" value="HTML5" />
</beans:bean>
<beans:bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
<beans:property name="templateResolver" ref="templateResolver" />
</beans:bean>
<beans:bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
<beans:property name="templateEngine" ref="templateEngine" />
</beans:bean>
4. home.html
### html
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring3-3.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Thymeleaf Home</title>
</head>
<body>
<h1>Thymeleaf Hello world!</h1>
<P>The time on the server is</P>
</body>
</html>
참고 |
http://www.thymeleaf.org/springsecurity.html
'Tip > Spring' 카테고리의 다른 글
[타임리프] From JSP to Thymeleaf (0) | 2013.07.30 |
---|---|
[Maven] thymeleaf-extras-springsecurity3-2.0.0 다운로드 실패 (0) | 2013.07.29 |
Jackson library 이용하여 date format 변경하기 (0) | 2013.07.08 |
Spring Security 를 이용하여 로그인여부 화면에 표시하기 (0) | 2013.04.18 |
web.xml 에서 classpath 사용시 주의사항 (0) | 2013.04.16 |