首页 > 解决方案 > spring框架如何加载context.xml文件

问题描述

在此处输入图像描述

这是 STS 创建的默认项目。

下面有xml代码

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:beans="http://www.springframework.org/schema/beans"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/mvc 
  http://www.springframework.org/schema/mvc/spring-mvc.xsd
  http://www.springframework.org/schema/beans 
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/context 
  http://www.springframework.org/schema/context/spring-context.xsd">

  
  <annotation-driven /> 



  <resources mapping="/resources/**" location="/resources/" /> 



  <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
  </beans:bean>
  
  <context:component-scan base-package="com.hee.heechart" /> - 
 
</beans:beans>

我不明白.. springframework 如何加载 context.xml 文件

servlet-context.xml文件和root-context.xml文件效果很好,但是不知道加载root-context.xml文件和servlet-context.xml文件的springframework结构。

是否可以在 WEB-INF 文件夹中加载 appServlet 文件夹,因为它位于类路径中?

标签: javaxmlspring

解决方案


推荐阅读