Table of Contents |
---|
Mustache 의 자바 파생인 handlebarsjs 의 자바 구현물인 handlebars.java 와 스프링 mvc 연동
...
테스트
Controller 추가
Code Block | ||
---|---|---|
| ||
package com.example.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; @Controller public class HelloController { @RequestMapping(value = "/hello", method = RequestMethod.GET) public ModelAndView hello(@RequestParam(value = "name", required = false) String name) { ModelAndView m = new ModelAndView("hello"); m.addObject("name", name); m.addObject("message", "Hello world!"); return m; } } |
...
webapp/resources/handlebars/hello.hbs
Code Block | ||||
---|---|---|---|---|
| ||||
<!DOCTYPE html> <html> <head> <title>handlebars test</title> </head> <body> <h1> handlebars test</h1> Hello "{{ this.name }}"<br/> message: {{this.message}}!<br/> class: "{{ this }}" </body> </html> |
...