在servlet中使用spring注解


@Autowired
IAgreementPayService agreementPayService;

/**
* 支付参数
*/
@Value("B{agreementPay.publicKey}")
private String publicKey;

/**
* 启动初始化上下文
*/
@Override
public void init() throws ServletException {
  super.init();
  ServletContext application = this.getServletContext();
  // 解决servlet用@Autowired自动注入service失败的问题
  SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, application);
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM