2013-07-23 17:01:50 +08:00
|
|
|
package app
|
|
|
|
|
2013-12-19 21:40:10 +08:00
|
|
|
@Grab("thymeleaf-spring4")
|
2013-05-31 23:16:19 +08:00
|
|
|
@Controller
|
|
|
|
class Example {
|
|
|
|
|
|
|
|
@RequestMapping("/")
|
|
|
|
public String helloWorld(Map<String,Object> model) {
|
|
|
|
model.putAll([title: "My Page", date: new Date(), message: "Hello World"])
|
|
|
|
return "home";
|
|
|
|
}
|
2013-07-22 23:20:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
@Log
|
|
|
|
class MvcConfiguration extends WebMvcConfigurerAdapter {
|
|
|
|
|
2013-07-23 22:47:26 +08:00
|
|
|
@Override
|
|
|
|
void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
log.info "Registering interceptor"
|
|
|
|
registry.addInterceptor(interceptor())
|
|
|
|
}
|
2013-07-22 23:20:19 +08:00
|
|
|
|
2013-07-23 22:47:26 +08:00
|
|
|
@Bean
|
|
|
|
HandlerInterceptor interceptor() {
|
|
|
|
log.info "Creating interceptor"
|
|
|
|
[
|
|
|
|
postHandle: { request, response, handler, mav ->
|
|
|
|
log.info "Intercepted: model=" + mav.model
|
|
|
|
}
|
|
|
|
] as HandlerInterceptorAdapter
|
|
|
|
}
|
2013-05-31 23:16:19 +08:00
|
|
|
}
|