'Thymeleaf'에 해당되는 글 1건

  1. 2016.11.15 Spring Boot, Thymeleaf - Hello World Example 예제

Spring Boot Hello World Example with Thymeleaf

 

스프링부트, 타임리프 헬로월드 예제

* pom.xml



    4.0.0
    hello-springboot
    hello-springboot
    hello-springboot
    
        org.springframework.boot
        spring-boot-starter-parent
        1.3.5.RELEASE
    

    
        1.7
    

    
        
            org.springframework.boot
            spring-boot-starter-thymeleaf
        
    
    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

* HelloController.java

package com.hellokoding.springboot;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class HelloController {
    @RequestMapping("/hello")
    public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) {
        model.addAttribute("name", name);
        return "hello";
    }
}

* hello.html




    
    


    

* WebApplication.java

package com.hellokoding.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

@SpringBootApplication
public class WebApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(WebApplication.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(WebApplication.class, args);
    }
}

* application.properties

spring.thymeleaf.cache: false

Run

mvn spring-boot:run

Source code

git@github.com:hellokoding/springboot-thymeleaf.git https://github.com/hellokoding/springboot-thymeleaf

'※ Jimmy's > web 개발' 카테고리의 다른 글

Java type change String to Date.  (0) 2017.04.25
jstl date 날짜계산  (0) 2017.04.25
Thymeleaf - Html 에서 조건문 삽입 및 출력값 변경  (0) 2016.11.15
안드로이드 캐시제거  (0) 2014.08.23
꿀팁  (0) 2014.08.23
Posted by JimmyUm
,