spring配置文件介绍
spring的配置文件比较固定,这里以springmvc的配置文件为例介绍,beans是根标签,xmlns是name space的简称,一般xmlns有beans、XMLSchema-instance、mvc、context
、tx。xml中用到什么标签必须要在xmlns中注明。下面的schemaLocation地址是上面声明所要遵守的规范。
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd "> <!-- 将带有注解的类加入到spring容器中 --> <context:component-scan base-package="cn.itcast.javaee.springmvc.app15"/> </beans>