First, what is SPRINGMVC
Springmvc is a very good MVC framework.
SPRINGMVC is more excellent than Struct2. As for the reasons, we can first understand briefly, SPRING4MVC is in the back of the Struct2, Springmvc occupy the post-advantage. For other reasons, after finishing this course, we will make a detailed comparison.
Second, how to download Spring jar package from official website
Whether learning programming language or framework, the individual thinks that it spends a lot of time searching for information, it is better to study the official website, the official website is the best learning material. Now take a look at Spring's official website.
1, Spring's official website address
http://spring.io/
650) this.width=650; "title=" D6ACDB7B-FABC-4ADB-A2A8-EFBB9D034AFB "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" D6ACDB7B-FABC-4ADB-A2A8-EFBB9D034AFB "src=" http:// S3.51cto.com/wyfs02/m00/76/e9/wkiol1zevnot4ytyaaapzrk_qia072.jpg "height=" 121 "/>
See this clean and clean interface, the navigation is very clear.
2. Enter projects
650) this.width=650; "title=" b768a02e-2c32-4ecb-b5f1-11cf19061402 "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" b768a02e-2c32-4ecb-b5f1-11cf19061402 "src=" http:// S3.51cto.com/wyfs02/m00/76/e9/wkiol1zevnwhyxsqaab5bvcymzg895.png "height=" 212 "/>
Spring's coverage is very broad, what you need to find in the page shown, this page is very clear, it is easy to find the spring framework, there is an English introduction provides core support for dependency injection, Transaction management, Web apps, data access, messaging and more. (Provides core functionality dependency injection, transaction management, Web applications, data access, remote access, etc.)
3. Enter the Spring Framework page we need
650) this.width=650; "title=" 79e44c2e-cda7-4660-8574-fffdb39e7445 "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 79e44c2e-cda7-4660-8574-fffdb39e7445 "src=" http:// S3.51cto.com/wyfs02/m01/76/e9/wkiol1zevneid9sraabs5_yuxag214.png "height=" 181 "/>
This page contains descriptions, feature descriptions, requirements for the JDK for the spring Framework version, and a sample wizard if you build a project using MAVEN or Gradle.
The most important thing is that under the characteristics of this paragraph, you need to note:
650) this.width=650; "title=" 06325e8e-ac78-4fef-856c-dd7ba4f715e0 "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 06325e8e-ac78-4fef-856c-dd7ba4f715e0 "src=" http:// S3.51cto.com/wyfs02/m02/76/ea/wkiom1zevhdterq-aaaev77djoo323.png "height="/>
This passage is very clear and tells us to click on the link on this paragraph, which is dedicated to all the features and modules and the relationship between the modules. Click the link to enter, you can see this page
650) this.width=650; "title=" 924362c5-358d-45f2-9479-3e2abd3ea101 "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 924362c5-358d-45f2-9479-3e2abd3ea101 "src=" http:// S3.51cto.com/wyfs02/m00/76/ea/wkiom1zevhgadkghaaa_nuysxss055.png "height=" 142 "/>
4. Download jar
This is a very detailed introduction to the spring framework, so it's important to take a look at it, so there's our spring jar package link and instructions on this page.
650) this.width=650; "title=" 499c15a4-bf1e-4e20-b2fe-bff0dbc47f98 "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 499c15a4-bf1e-4e20-b2fe-bff0dbc47f98 "src=" http:// S3.51cto.com/wyfs02/m01/76/ea/wkiom1zevhkc3hnxaaap1bhyzks957.png "height=" "/>"
We found each of the spring versions of: http://repo.spring.io/release/org/springframework/spring
650) this.width=650; "title=" 83ccf02e-e63b-43e8-8725-167ce8f82c78 "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 83ccf02e-e63b-43e8-8725-167ce8f82c78 "src=" http:// S3.51cto.com/wyfs02/m01/76/e9/wkiol1zevnvx3mqiaabb2xba4li272.png "height=" 244 "/>
Third, install spring plug-in for MyEclipse 1, download Spring's Elcipse plug-in
Enter spring's website address on the browser: Http://spring.io
At the bottom of the homepage, you can see "Tools"
650) this.width=650; "title=" 0ae127af-c3b8-4d4b-9f84-9e9dabe74f51 "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 0ae127af-c3b8-4d4b-9f84-9e9dabe74f51 "src=" http:// S3.51cto.com/wyfs02/m02/76/ea/wkiom1zevhty1tzeaaakk6ko_rw657.png "height="/>
Click to enter
650) this.width=650; "title=" 67b06d91-f494-404d-bc87-e1933f6e76db "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 67b06d91-f494-404d-bc87-e1933f6e76db "src=" http:// S3.51cto.com/wyfs02/m01/76/ea/wkiom1zevhxqnplwaabtz20llwm552.png "height=" 106 "/>
This page details the use of STS, but we need the eclipse plugin, we clicked on the "Download" link
650) this.width=650; "title=" 0a9dc8ca-8299-46e9-87aa-2b3fdc428d3a "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 0a9dc8ca-8299-46e9-87aa-2b3fdc428d3a "src=" http:// S3.51cto.com/wyfs02/m00/76/e9/wkiol1zevn7wfvjnaabnehdxhps951.png "height=" 126 "/>
There are two ways to install offline and install online.
2. View the version of Eclipse in MyEclipse
650) this.width=650; "title=" cea7a1b0-b768-4f4f-8835-842992252a8e "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" cea7a1b0-b768-4f4f-8835-842992252a8e "src=" http:// S3.51cto.com/wyfs02/m02/76/ea/wkiom1zevhiinwgwaab7ski4seu363.png "height=" 241 "/>
650) this.width=650; "title=" 7ae94f65-39a5-48a3-bee0-1861abdfc44b "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 7ae94f65-39a5-48a3-bee0-1861abdfc44b "src=" http:// S3.51cto.com/wyfs02/m01/76/e9/wkiol1zevogyxqfgaabamf2zgq8584.png "height=" 104 "/>
650) this.width=650; "title=" 63632c5b-1a53-4a11-b0c7-d657c6bc953a "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 63632c5b-1a53-4a11-b0c7-d657c6bc953a "src=" http:// S3.51cto.com/wyfs02/m02/76/e9/wkiol1zevolcp7tjaabdxz9neic885.png "height=" 244 "/>
3. Installation
650) this.width=650; "title=" b1a8729b-d402-4e3a-9e42-62fb39c05e3c "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" b1a8729b-d402-4e3a-9e42-62fb39c05e3c "src=" http:// S3.51cto.com/wyfs02/m00/76/ea/wkiol1zevoojxx5paab67m2xczk957.png "height=" 239 "/>
650) this.width=650; "title=" bc1c78d5-342b-4300-aa88-85fb19836745 "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" bc1c78d5-342b-4300-aa88-85fb19836745 "src=" http:// S3.51cto.com/wyfs02/m01/76/ea/wkiol1zevowxqivvaab_imuzwty097.png "height=" 206 "/>650) this.width=650;" Title= " fd9d353d-0191-40be-bd47-1ee55af0e535 "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "fd9d353d-0191-40be-bd47-1ee55af0e535" src= "http://s3.51cto.com/wyfs02/M02/76/EA/ Wkiol1zevobjvr49aab1qji1jtg672.png "height=" 199 "/>
Iv. The first SPRINGMVC project: HelloWorld
1. Add Jar Package 1.1 Spring Package
Spring-aop-4.2.1.release.jar
Spring-beans-4.2.1.release.jar
Spring-context-4.2.1.release.jar
Spring-core-4.2.1.release.jar
Spring-expression-4.2.1.release.jar
Spring-web-4.2.1.release.jar
Spring-webmvc-4.2.1.release.jar
1.2 Dependent Packages
2. Configuring Dispatcherservlet in Web. xml
<!-- 配置 DispatcherServlet -->
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置 DispatcherServlet 的一个初始化参数: 配置 SpringMVC 配置文件的位置和名称 -->
<!--
实际上也可以不通过 contextConfigLocation 来配置 SpringMVC 的配置文件, 而使用默认的.
默认的配置文件为: /WEB-INF/<servlet-name>-servlet.xml
-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
3 Add SPRINGMVC configuration file 3.1 springmvc.xml in src directory
<?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-4.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
</beans>
3.2 Configuring the scan package in Springmvc.xml
<!-- 自动扫描包 -->
<context:component-scan base-package="cn.imentors.springmvc.handlers"/>
3.3 Configuring the View resolver
<!-- 配置视图解析器:如果把handler方法返回值解析为实际的物理视图 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
Note: Internalresourceviewresoler is parsed as follows
prefix+returnval+ suffix (suffix)
4 Writing a slice is the requested processor and identifies writing a class for processor 4.1
public class HelloWrold {
public String hello(){
System.out.println("Hello World");
return "success";
}
}
4.2 Identify this class as @controller
@Controller
public class HelloWrold {
4.3 Mapping the requested URL by @requestmapping annotations
/**
* 通过@RequestMapping来注解请求的URL
* @return
*/
@RequestMapping("/helloworld")
public String hello(){
5 Writing Views 5.1 index.jsp
<a href="helloworld">helloworld
5.2 success.jsp
4>success
6. Summary
SPRINGMVC's work flow. Here is a brief introduction, Springmvc detailed work principle, and so we take this course to learn the door, and then for analysis.
User request
Controller
Back to view
Follow us
The purpose of space division is to share knowledge and spread value. Follow us and get more information in a timely manner.
650) this.width=650; "title=" 3062427b-baa4-43b2-a858-023f10d898a8 "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" 3062427b-baa4-43b2-a858-023f10d898a8 "src=" http:// S3.51cto.com/wyfs02/m01/76/eb/wkiom1zevidsh-2maabj0d43hdq354.png "height=" 244 "/>
Donate US
If you agree with our results and feel that it is helpful to you, you are welcome to donate ^_^ to us.
650) this.width=650; "title=" F909cdb7-e572-4a4f-912d-77e397429ebb "style=" border-top:0px;border-right:0px; border-bottom:0px;border-left:0px; "border=" 0 "alt=" F909cdb7-e572-4a4f-912d-77e397429ebb "src=" http:// S3.51cto.com/wyfs02/m00/76/ea/wkiol1zevonyfno6aabnwr0s9po683.jpg "height=" 244 "/>
This article is from the "Division Space" blog, please be sure to keep this source http://imentors.blog.51cto.com/10946447/1718973
01-springmvc-helloworld