【问题标题】:How does init() get called on a Handler in a WebApp如何在 WebApp 中的 Handler 上调用 init()
【发布时间】:2010-05-18 18:51:27
【问题描述】:

我有一个 Handler 对象,它的功能有点像服务。它在实现中定义了一个公共 init 方法,但在接口中没有。这个处理程序也通过 Spring 自动装配。 init 方法是如何被调用的?是通过 Spring 还是 Tomcat 调用它?

【问题讨论】:

    标签: java spring tomcat initialization autowired


    【解决方案1】:

    如果是春天,init-method 属性应该可以解决问题。同样,可以实现InitializingBean#afterPropertiesSet 方法,在该方法中可以调用init

    如果您在 spring 中没有看到为您的 bean 声明指定 init-method 属性,请在根标记 beans 中查找 default-init-method="init" 属性声明。

    【讨论】:

      猜你喜欢
      • 2011-11-09
      • 1970-01-01
      • 2019-05-06
      • 1970-01-01
      • 2016-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多