【问题标题】:Spring session-scoped bean with construtor argument具有构造函数参数的 Spring 会话范围 bean
【发布时间】:2014-02-28 05:46:58
【问题描述】:

在 Spring 中,我有一个不应该在没有依赖于用户输入的构造函数参数的情况下实例化的 bean。在控制器或另一个 Singleton-Scoped bean 中实例化 SessionScoped bean 的正确方法是什么?

public class SingletonScoped{
    ...
}

public class SessionScoped{
    @Autowired
        SingletonScoped singletonScopped;

    private SessionScoped(){
    }

    public SessionScoped(Object userInput){

    }

}

 public class AnotherSingletonScoped{
    ...
}

【问题讨论】:

    标签: java spring spring-mvc


    【解决方案1】:

    基本上我应该在 serverlet-context.xml 中添加 spring 参数,然后你可以在这里传递参数。你可以在这篇文章中看到更多细节http://chiase.azurewebsites.net/?p=171

    【讨论】:

    • 请添加更多细节。这个答案真的很差。
    • 根据the guidelines,您不应该在未发布相关内容的情况下发布链接-链接可能会断开,然后此答案将不再对用户有所帮助。
    猜你喜欢
    • 2011-12-26
    • 2021-11-17
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    • 2012-10-31
    • 2012-02-05
    • 1970-01-01
    相关资源
    最近更新 更多