You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
745 B
Groovy
35 lines
745 B
Groovy
11 years ago
|
package app
|
||
|
|
||
11 years ago
|
import groovy.util.logging.Log
|
||
|
|
||
12 years ago
|
@Grab("org.thymeleaf:thymeleaf-spring3:2.0.16")
|
||
|
@Controller
|
||
|
class Example {
|
||
|
|
||
|
@RequestMapping("/")
|
||
|
public String helloWorld(Map<String,Object> model) {
|
||
|
model.putAll([title: "My Page", date: new Date(), message: "Hello World"])
|
||
|
return "home";
|
||
|
}
|
||
11 years ago
|
}
|
||
|
|
||
|
@Configuration
|
||
|
@Log
|
||
|
class MvcConfiguration extends WebMvcConfigurerAdapter {
|
||
|
|
||
11 years ago
|
@Override
|
||
|
void addInterceptors(InterceptorRegistry registry) {
|
||
|
log.info "Registering interceptor"
|
||
|
registry.addInterceptor(interceptor())
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
@Bean
|
||
|
HandlerInterceptor interceptor() {
|
||
|
log.info "Creating interceptor"
|
||
|
[
|
||
|
postHandle: { request, response, handler, mav ->
|
||
|
log.info "Intercepted: model=" + mav.model
|
||
|
}
|
||
|
] as HandlerInterceptorAdapter
|
||
|
}
|
||
12 years ago
|
}
|