之前有个项目需要在servlet中调用service(其实完全可以用Controller),但是servlet中添加@Controller或者@Component都无效,运行就报空。

在网上搜了很多方法,一个个尝试下来,最终解决,先记下来,以免下次特殊情况需要

一、在context中配置service

Spring MVC在servlet中调用service

二、在servlet中实例化context

Spring MVC在servlet中调用service

然后就可以用context调用service了

Spring MVC在servlet中调用service


相关文章:

  • 2022-12-23
  • 2021-12-06
  • 2021-07-26
  • 2022-02-04
  • 2022-12-23
  • 2021-04-02
猜你喜欢
  • 2022-12-23
  • 2021-10-02
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
相关资源
相似解决方案