Spring configuration file XML header information resolution one

Source: Internet
Author: User

We use the Spring framework when the first to configure its XML file, a lot of header information exactly what it represents, here to summarize their own understanding ...

Here is the XML file header content that comes with the Web project when you create it:

<? XML version= "1.0" encoding= "UTF-8" ?> <  xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"         xmlns= "http ://xmlns.jcp.org/xml/ns/javaee "         xsi:schemalocation=" http://xmlns.jcp.org/xml/ns/ Java EE         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd "  ID=" webapp_id " Version= "3.1">

This is the spring header information we have configured:

<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns:p= "http://www.springframework.org/schema/p"Xmlns:context= "Http://www.springframework.org/schema/context"XMLNS:AOP= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"Xmlns:tx= "Http://www.springframework.org/schema/tx"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-3.0.xsd Http://www.springframework.org/schema/context Http://www.springframework.org/schema/context /spring-context-3.0.xsd Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/ Spring-tx-3.0.xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP http://www.springframework.org/schema/aop/ Spring-aop-3.0.xsd ">

In contrast, it can be found that they all have: the declaration as an XML file, version 1.0, encoded as UTF-8, which is easy for everyone to understand.

But xmlns:xsi ...; xmlns ...; Xsi:schemalocation ...; What do these configurations represent???

After summing up the experience of online predecessors, here to say their own understanding:

First of all, XML is a strict markup language (as opposed to HTML), such as the need to have an end tag, and others know that because of its strict characteristics, and can be based on the needs of individuals to add new tags, often used as a project configuration file use.

Then the need to become a strict XML tag language needs to have its rules to constrain, our new standard XML file contains xmlns:xsi ...; xmlns ...; Xsi:schemalocation ..... As shown above, the Xmlns= namespace, xsi=xml-schema-instance (XML template instance, standard is so named, good official), know these we know the standard Web. xml file content what these are.

The header information for Web. XML:

1.Xmlns:xsi=http://www.w3.org/2001/xmlschema-instance declares that the contents of the file can use the XSI tag library,

2.xmlns= "Http://xmlns.jcp.org/xml/ns/javaee" declaration the use of the label is used by Java EE Development

3.xsi:schemalocation= "Http://xmlns.jcp.org/xml/ns/javaee declaration can be used by the tag library and corresponding to the specific tag library version address.

so spring's header information is:

1.xmlns=http://www.springframework.org/schema/beans represents the XML configuration file for spring beans

2.XMLNS:XSI;XMLNS:CONTEXT;XMLNS:AOP;XMLNS:TX, declare that you can use standard XML tags (xsi), or you can use tags from a tag library such as CONTEXT;AOP;TX, That is, the declaration of xmlns: after the content can be used as a label rule in the XML file, not included in the use of the error (as a strict markup language characteristics).

3.xsi-schemalocation This is a grammatical rule contract (xmlns is also, whereas xmlns:xsi is just the rule of declaring tags), the content after the equals sign is the specific tag library that is introduced and the address of the specific version rule that corresponds to the tag library to be used in the text.

Spring configuration file XML header information resolution one

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.