加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

默认加载applicationContext.xml执行两边init-method的问题(WSS

发布时间:2020-12-16 09:15:19 所属栏目:百科 来源:网络整理
导读:-----------------------------------------①----------------------------------------------------- 一般情况下,不写 下面的代码,就无法加载spring的配置文件 listener listener-classorg.springframework.web.context.ContextLoaderListener/listener-

-----------------------------------------①-----------------------------------------------------

一般情况下,不写 下面的代码,就无法加载spring的配置文件

 <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>


它默认加载“ /WEB-INF/ ”路径下的applicationContext.xml,如果想加载“/WEB-INF/classes/ ”路径下的applicationContext.xml,需要下面代码

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/classes/*Context.xml</param-value>
  </context-param>

------------------------------------------②-----------------------------------------------------

如果一个web项目,加载了applicationContext.xml,但是在web.xml中没写上面两端代码,可能是因为这是一个WS,

<listener>
	<listener-class>
		com.sun.xml.ws.transport.http.servlet.WSServletContextListener
	</listener-class>
</listener>


上面这段代码,会默认从classpath中加载applicationContext.xml,改名字不会加载

----------------------------------------------------------------------------------------------

所以,如果一个WebService项目,web.xml中写了②中的代码,不能在加①中的代码,否则会加载两边,如果有初始化方法会出现问题

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读