我有Grails 2.5.6
应用程序正在使用Spring Security Grails plugin
,并且应用程序中有一个过滤器来检查是否存在如果不存在则继续正常运行,如果没有必须转到控制器Country
,操作countryAndCity
,访问过滤器之前的 URL 是https://localhost:8443/MyApp/login/auth
在执行过滤器之后重定向 URL 是http://localhost:8080//countries/countryAndCity
,
是什么在 URL 中造成了这种奇怪的行为?以下是在此阶段执行的 2 个过滤器:
SwitchToHTTPS过滤器:
def filters = {
// to redirect to HTTPS for the below actions
all(controller: 'users|login|countries', action: 'create|auth|*', actionExclude: 'logout') {
before = {
if (!request.isSecure()) {
def url = "https://" + request.serverName + ':8443' + request.forwardURI
redirect(url: url, permanent: true)
return false
}
}
after = {Map model ->
}
afterView = {Exception e ->
}
}
}
SetCountryAndCityFirstFilters:
// for the Users controller set country and city first
def filters = {
all(controller: 'users', action: 'create') {
before = {
if (session.countryAndCity == null) {
session.forwardToURI = request.forwardURI
redirect(controller: "countries", action: "countryAndCity")
}
}
after = {Map model ->
}
afterView = {Exception e ->
}
}
}