grails - 依赖注入(inject) Grails Webflow

标签 grails groovy spring-webflow

是否可以将 Spring bean 注入(inject) Grails webflow?我尝试了以下

class CheckoutController {

    ShoppingService shoppingService

    def checkoutFlow = {
        start {
            action {
                // This attempt to access the service doesn't work
                flow.addresses = shoppingService.getOrder()
            }
        }
    }
}

我可以访问shoppingService从常规 Controller 操作,但我无法从 webflow 的操作访问它(见上文)。

最佳答案

将以下内容添加到您的 Controller :

def transient shoppingService 

关于grails - 依赖注入(inject) Grails Webflow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7306519/

相关文章:

grails - 运行 “grails activiti-quickstart”时显示依赖项错误

javascript - jQuery/Grails将多个选项/值标记为在多个选择框中选择

bash - 如何在 Groovy 中进行 shell 扩展?

spring-webflow - Spring Web Flow LockTimeoutException

java - Webflow 与 Angular 还是两者兼而有之?

spring - 无法找到元素 'flow' 的 Spring NamespaceHandler

image - Grails应用程序镜像路径?

grails - 在Grails中使用findBy()时出错

grails - 在 grails 3 拦截器中的每个请求上添加一个响应头

java - GroovyClassLoader 和 permgen