我正在使用Grails 2.0.0,并尝试从Bootstrap.groovy预填充一些测试数据。此数据需要来自Grails taglib的createLinkTo
。
顺便说一句,当我试图打电话给g.createLinkTo(...)
时:
Message: No thread-bound request found: Are you referring to request attributes outside
of an actual web request, or processing a request outside of the originally receiving
thread? If you are actually operating within a web request and still receive this message,
your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this
case, use RequestContextListener or RequestContextFilter to expose the current request.
而且,这个应用程序将在后台线程中使用createLinkTo
(事件处理,发送邮件等)。所以我不仅在Bootstrap中需要它。
据我所知,我需要发出一个模拟请求,并将其绑定到当前线程,但我该怎么做呢?
或许还有另一种方法可以建立应用链接?