Spring Controller中的Init方法(注解版) [英] Init method in Spring Controller (annotation version)

查看:44
本文介绍了Spring Controller中的Init方法(注解版)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将控制器转换为较新的注释版本.在旧版本中,我使用以下命令在 springmvc-servlet.xml 中指定 init 方法:

I'm converting a controller to the newer annotation version. In the old version I used to specify the init method in springmvc-servlet.xml using:

<beans>
    <bean id="myBean" class="..." init-method="init"/>
</beans>

如何使用注解版本指定init方法?

How can I specify the init method using the annotation version?

推荐答案

可以使用

@PostConstruct
public void init() {
   // ...
}

这篇关于Spring Controller中的Init方法(注解版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆