Understanding xml Schema

I am trying to understand the xmlns definition point of the following xml file:

<beans xmlns="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"
    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">   
</beans>

I did not understand what is indicated here by schemaLocation. Why, for instance, should be added to both attributes xmlns:mvc = "http://www.springframework.org/schema/mvc", and http://www.springframework.org/schema/mvcan attribute schemaLocationto use mvc:xxx_something_xxxin my spring config file?

I just want to understand what I do every time I start creating spring-mvc applications, and not just copy them from Google without understanding.

+4
source share
2 answers

xmlnsdefines a namespace. If you want to use mvc:xxx, you must determine what a namespace is mvc.

xsi:schemaLocation , XSD ( XML).

, , , XML, .

:

+1

:

  • xmlns:mvc="http://www.springframework.org/schema/mvc" - , : ", " mvc " XML-, "; xmlns ,
  • schemaLocation="http://www.springframework.org/schema/mvc" - , Java Linux, , XML- XSD; , XSD

, ( xmlns="http://www.springframework.org/schema/beans").

, .

+1

Source: https://habr.com/ru/post/1569539/


All Articles