2016-11-23 35 views
-1

我需要将一个参数从控制器传递给拦截器的after()动作。我怎样才能做到这一点?将参数从控制器传递给拦截器在Grails 3.x中的()操作之后

+0

创建另一个动作,模仿这个动作,然后将其发送到动作2,将打拦截之前是和你实际上是打拦截后 - 我想你大概的意思/需要验证,而不是拦截器 - 如果问题不能回{显示表单或其他内容}和/或如果没问题然后继续下一步 - 验证是针对那个 – Vahid

+0

最好的解决方案将取决于信息是什么,它是否也需要在视图中可访问,以及您想用它做。 –

+0

我想在视图中显示该参数,该参数需要设置为在Interceptor中的after()动作中建模。 – thagunnaHarish

回答

0

在拦截器关闭之前,您有请求和响应对象可用,但请求/响应对象的作用域在以模型对象为参数的关闭之后执行完成。

class YourInterceptor { 
    boolean before(){ 
    //code before reaching respective controller 
     return true 
    } 
    //this part is executed before the view is rendered, 
    def afterInterceptor = { model -> 
     def myParam = model.yourParam; 
    } 
} 

You can set the model object used above in your controller as 
public class YourController { 
    //your controller logic 
[yourParam: paramValue] // this map is the model object which contains `the data for your view, this object is the model object that is used in after closure of interceptor.` 
} 
+0

由于我必须将控制器中的客户端特定参数传递给after()方法(将其设置为model)并最终查看,所以此处出现此问题。在这里,没有会话已经启动,因为在没有访问该特定用户的情况下它必须从登录页本身返回。 Single Sign On系统出现此问题,用户可以访问客户端,但不能访问其他客户端。 – thagunnaHarish

相关问题