• 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属性了-->

  • 相关阅读:
    docker简单介绍----Dockerfile命令
    docker简单介绍----docker仓库的应用
    nginx实现https的配置文件
    docker简单介绍---网络端口管理
    mysql查看实时连接数
    linux 批量测试域名返回码脚本
    docker简单介绍----镜像和容器管理
    香冢
    GitHub 在使用命令行 git push 时报错:The requested URL returned error: 403
    守规矩应该被骂吗?
  • 原文地址:https://www.cnblogs.com/zhanzhuang/p/9455371.html
Copyright © 2020-2023  润新知