如何用Spring将Service注入到Servlet中

如何用Spring将Service注入到Servlet中,第1张

在applicationContextxml中定义数据层访问Bean:
<bean id="userDao" class="testUserDaoImpl"></bean>
public class MyServlet extends >如何在Java Filter 中注入 Service
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// 初始化方法
ServletContext sc = filterConfiggetServletContext();
XmlWebApplicationContext cxt = (XmlWebApplicationContext)WebApplicationContextUtilsgetWebApplicationContext(sc);
if(cxt != null && logManager == null)
logManager = (LogManager)cxtgetBean("logManager");
}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/10786194.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-11
下一篇2023-05-11

发表评论

登录后才能评论

评论列表(0条)

    保存