Spring framework web project actual full code sharing
The following is the simplest example
1. Create a new standard Java Web project
2. Import some basic jar packages required by spring
3. Configure web XML file
4. Add spring configuration file ApplicationContext
5. For ApplicationContext XML file for the simplest configuration
Beans -- the root node of the XML file.
Xmlns -- is the abbreviation of xmlnamespace. Because the tag names of XML files are user-defined, the tags written by yourself and those defined by others are likely to be named repeatedly, but the functions are different. Therefore, a namespace needs to be added to distinguish this XML file from other XML files, similar to package in Java.
Xmlns: XSI -- refers to that the XML file complies with the XML specification. The full name of XSI: xmlschemainstance refers to the specification followed by the elements defined in the specific schema resource file. I.e. / spring-beans-2.0 XSD is the standard that the elements defined in this file comply with.
XSI: schemalocation -- refers to the specification followed by the XML elements in this document. The schemalocation attribute is used to reference the schema document. The parser can use this document to verify the XML instance document if necessary. Its values (URIs) appear in pairs. The first value represents the namespace, and the second value represents the specific location of the schema document describing the namespace. The two values are separated by spaces.
6. Create a new entity class user java
7. Testing
output
This enables the web project to build the basic spring framework. Next, we will do some extensions that will be used in real projects, which can be found on the web XML to configure some spring framework integrated functions or other settings
Jspf is to make some global declarations
Can be in ApplicationContext Configure more functions in XML
spring-mvc. XML file configuration
summary
The above is all about the actual code sharing of the spring framework web project. I hope it will be helpful to you. Interested friends can continue to refer to this website:
Spring MVC rest style introduction and implementation code example
Spring MVC interceptor for single sign on
Spring integrated redis detailed code example