일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |
- JPA mapping
- ORM
- 세미나
- 톰캣
- JPA
- Spring
- Data REST
- spring boot tomcat
- tomcat
- static inner class
- spring-webmvc #코드읽기
- SuperTypeToken
- spring camp
- spring-mvc
- 코드 리뷰
- spring-webmvc
- JUnit
- spring bean
- spring pid
- REST API
- Spring Data REST
- Spring Data JPA
- IntelliJ
- spring jpa
- Spring Batch
- batch
- spring batch 코드
- docker
- spring boot
- ApplicationPidFileWriter
- Today
- 1
- Total
- 916,386
woniper
spring boot-4(Velocity 설정과 사용) 본문
[spring] spring boot-1(특징과 기본 설정)
[spring] spring boot-2(프로젝트 구조와 Tomcat 연동 및 proerties사용)
[spring] spring boot-3(JPA 설정과 사용)
Velocity 설정
1. pom.xml
Velocity도 다른 설정과 마찬가지로 dependency만 추가 하면 모든 설정이 자동이다.
org.springframework.boot spring-boot-starter-velocity
2. application.properties
velocity를 사용할때 utf-8로 설정을 해야 한글이 깨지지 않는다.
spring.velocity.charSet=UTF-8
spring.velocity.properties.input.encoding=UTF-8
spring.velocity.output.encoding=UTF-8
Velocity 사용
1. vm 파일 생성
velocity는 *.vm이라는 확장자를 쓴다. html과 똑같다. 다만 확장자만 vm이고 velocity문법을 사용하기 위해서이다.
main > resources > telplates > index.vm 생성 후 아래 코드를 작성.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
#if(true)
this is true!!!
#end
</body>
</html>
velocity 기본 문법은 Velocity User Guide를 참고한다.
2. Controller
package net.woniper.springboot.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import java.util.List; /** * Created by woniper on 14. 10. 25.. */ @Controller @RequestMapping("/") public class MainController { @RequestMapping("/velocity") public String velocity() { return "index"; } }
localhost:8080/velocity로 접속해서 "this is true!!!"라고 뜨면 성공이다.
'Spring' 카테고리의 다른 글
Spring MVC (0) | 2015.05.07 |
---|---|
spring boot embedded tomcat CORS 적용 (0) | 2015.04.09 |
spring boot-3(JPA 설정 및 사용) (12) | 2014.10.25 |
spring boot-2(프로젝트 구조와 Tomcat 연동 및 proerties사용) (7) | 2014.10.25 |
spring boot-1(특징과 기본 설정) (0) | 2014.10.25 |