首页 > 编程知识 正文

spring框架的通俗理解,spring详解

时间:2023-05-06 17:06:31 阅读:48911 作者:1486

第一步:

在web.xml文件中配置spring的servletcontext监听文件和自己编写的servletcontext监听文件。 自己编写的servletcontext监听文件必须在spring文件之后从spring容器中检索对象。

上下文- param param-namecontextconfiglocation/param-name param-value class path :应用程序上下文. XML/param-varam context-paramlistenerlistener-class org.spring framework.web.context.contextloaderlistener/listener - listenerlistenerlistener-classcom.byte dance.CRM.web.listener.servlet context/listener-class/listener步骤2 :自己

publicclassservletcontextimplementsservletcontextlistener { @ overridepublicvoidcontextinitialized (servletcontextexteventservler dictypedaodictypedao=(dictypedao ) context.getbean(dictypedao ); dicvaluedaodicvaluedao=(dicvaluedao ) context.getbean(dicvaluedao ); listdictypelist=dictypedao.select all (; javax.servlet.servletcontextservletcontext=servletcontextevent.getservletcontext (for (dictypedictype 3360 list ) listdicvaluevalue=dicvaluedao.select value (代码; servlet context.set attribute (代码,值); } @ overridepublicvoidcontextdestroyed (servletcontexteventservletcontextevent ) }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。