zoukankan      html  css  js  c++  java
  • 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属性了-->

  • 相关阅读:
    arrayAppend.php
    C语言中一个语句太长用什么换行?
    date
    Mysql复制一条或多条记录并插入表|mysql从某表复制一条记录到另一张表
    Unable to load bean org.apache.struts2.dispatcher.multipart.MultiPartRequest
    javascript:location=location;">刷新</a>
    TestAbstract
    scanner=new Scanner(System.in); int i=scanner.nextInt();
    public static void Swap2
    JIRA 模块 bug管理工具
  • 原文地址:https://www.cnblogs.com/zhanzhuang/p/9455371.html
Copyright © 2011-2022 走看看