关于Spring配置文件xml文档的schema约束

最开始使用spring框架的时候,对于其配置文件xml,只是网上得知其使用方法,而不明其意。最近想着寻根问底的探究一下。以下是本文主要内容:

1、配置文件示例。

[html] view plain copy 

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"        
  3.     xmlns:mvc="http://www.springframework.org/schema/mvc"     
  4.     xmlns:tx="http://www.springframework.org/schema/tx"  
  5.     xmlns:aop="http://www.springframework.org/schema/aop"  
  6.     xmlns:context="http://www.springframework.org/schema/context"  
  7.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              
  8.     xsi:schemaLocation="                                               
  9.             http://www.springframework.org/schema/beans    
  10.             http://www.springframework.org/schema/beans/spring-beans.xsd    
  11.             http://www.springframework.org/schema/context     
  12.             http://www.springframework.org/schema/context/spring-context.xsd    
  13.             http://www.springframework.org/schema/mvc    
  14.             http://www.springframework.org/schema/mvc/spring-mvc.xsd  
  15.             http://www.springframework.org/schema/tx   
  16.             http://www.springframework.org/schema/tx/spring-tx.xsd  
  17.             http://www.springframework.org/schema/aop  
  18.             http://www.springframework.org/schema/aop/spring-aop.xsd "  
  19.     default-autowire="byName">  
  20. </beans>  

上 面是我们最常用的applicationContext.xml的配置文件的最开始部分,很多时候我们只是知道这些必须添加,但为什么,添加哪些都不甚清 楚。我们知道spring在启动的时候会验证 xml文档,这些引入的schema即用来验证配置文件的xml文档语法的正确性

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值