我有一个类似于的Groovy模板登录.tpl文件
layout 'layout.tpl', title: 'LOGIN',
content: contents {
// if(param.logout) p class: "alert", "You have been logged out"
// if(param.error) p class: "alert alert-error", "There was an error, please try again"
form id: 'loginForm', class: 'form-horizontal',
role: 'form', action: '/login', method: 'post', {
// BLAH here
}
}
这基本上是从Spring Boot示例web安全入门版翻译而来的,该版本使用Thymelaf。
如何访问请求/响应/会话等内部函数。?我需要破解一个中间控制器来手动将这些东西放入模型中吗?
Spring向模板视图公开RequestContext
(请参见AbstractTemplateView
)。在Spring Boot 1.1中,它被称为"弹簧"。在1.2中,它使用了Spring MVC中的默认名称:"springMacroRequestContext"。