学习框架的时候,比如MyBaits,springMVC,spirng的时候,都需要配置xml,xml如果没配置好,这些框架也是用不了的,下面给出springMVC的xml。
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<!--xmlns:tx代表开启事务;xmlns:context,不知道这一项代表什么,但是在spring里这一项很重要
;xmlns:mvc代表了开启式MVC;上面配置命名空间,可以理解为包名,有了命名空间,就不出出现元素重复的情况,
下面xsi:schemaLocation代表上面xsd的位置。xsd是dtd的升级,xml有了xsd之后就规定了该xml的
文档中出现的元素、文档中出现的属性、子元素、子元素的数量、子元素的顺序、元素是否为空、
元素和属性的数据类型、元素或属性的默认和固定值。而且这些都是可选的,点开链接,我们可以按照需要选择版本
-->
<context:component-scan base-package="iss.spmvc.tags" />
<!--需要扫描的包 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsproot" />
<property name="suffix" value=".jsp" />
</bean>
<!-- 定义视图解析器,定义JSP文件的前缀和后缀,在开发的时候,会方便很多 -->
<mvc:annotation-driven />
<!-- 开启MVC的注解 -->
</beans>