grails拦截跨域访问请求
2017-07-03 本文已影响0人
静静黑夜
class ApiInterceptor {
boolean before() {
println "before::::=================="
header( "Access-Control-Allow-Origin","*")// 这里的*注意一下允许所有人调用"http://local.test" )
header( "Access-Control-Allow-Credentials", "true" )
header( "Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE" )
header( "Access-Control-Max-Age", "3600" )
true
}
boolean after() {
true
}
void afterView() {
// no-op
}
}