spring-mvc.xml与spring-mybatis.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: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.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <!-- 添加注解驱动(启动spring-mvc注解驱动) -->
    <mvc:annotation-driven/>
    <!-- 扫描web相关的bean  @Controller-->
    <context:component-scan base-package="com.six.controller"/>
    <!-- 配置一个检察员对进入DispatcherServlet的URL进行检查,如果是静态资源交给WEB应用服务器默认的Servlet处理如果不是静态资源
     继续交给DispatcherServlet处理-->
    <mvc:default-servlet-handler/>
    <!-- 定义跳转的文件的前后缀 ,视图模式配置 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
    <!-- 配置返回json类型的数据开始 -->
    <bean
            class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
        <property name="messageConverters">
            <list>
                <ref bean="jsonHttpMessageConverter"/>
            </list>
        </property>
    </bean>
    <bean id="jsonHttpMessageConverter"
          class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>application/json;charset=UTF-8</value>
            </list>
        </property>
    </bean>
    <!-- 配置返回json类型的数据结束 -->
</beans>

Schema 是对XML文档结构的定义和描述,其主要的作用是用来约束XML文件,并验证XML文件有效性。

xmlns 是 xml namespace的缩写也就是XML的命名空间,xmlns属性可以在文档中定义一个或者多个可供选择的命名空间。

xmlns="http://www.springframework.org/schema/beans"  <!--默认的命名空间,表示未使用其他命名空间的所有标签的默认命名空间-->

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  <!--xsi标准命名空间,用于指定自定义命名空间的schema文件,声明之后就可以使用schemaLocation属性了-->

转载于:https://www.cnblogs.com/zhanzhuang/p/9455371.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值