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.
spring-boot/spring-boot-project/spring-boot-cli/samples/ui.groovy

33 lines
735 B
Groovy

package app
@Grab("thymeleaf-spring5")
@Controller
class Example {
@RequestMapping("/")
public String helloWorld(Map<String,Object> model) {
model.putAll([title: "My Page", date: new Date(), message: "Hello World"])
return "home";
}
}
@Configuration(proxyBeanMethods = false)
@Log
class MvcConfiguration extends WebMvcConfigurerAdapter {
@Override
void addInterceptors(InterceptorRegistry registry) {
log.info "Registering interceptor"
registry.addInterceptor(interceptor())
}
@Bean
HandlerInterceptor interceptor() {
log.info "Creating interceptor"
[
postHandle: { request, response, handler, mav ->
MvcConfiguration.log.info "Intercepted: model=" + mav.model
}
] as HandlerInterceptorAdapter
}
}