Spring MVC environment construction and basic operations, springmvc
Spring MVC is a follow-up product of SpringFrameWork and has been integrated into Spring Web Flow. The Spring framework provides a full-featured
Spring MVC is a follow-on product of springframework and has been integrated into spring Web flow. The Spring framework provides a full-featured MVC module for building WEB applications. Using the spring pluggable
If you create a Spring projectSpring MVC Framework in Java Web project should be no one knows, you do not build a Spring framework? As a just learning Java I will, if you do not, that is really sad.1. After you create a project in MyEclipse, you can go to 配置 a Spring project in the selected way, which is not discussed
Spring MVC source handlermapping and Handleradapter analysisThis article is not a specific analysis Spring MVC, so a lot of detail is a stroke, mainly to show you the entire Spring MVC implementation process, and how to find the
Introduction
Unit Testing of the controller layer can improve the reliability of the application, although this makes the development of the time has increased, there will be lost, here I think to get more than lost. The unit test method after the
sping MVC3.2 version has changed, and unit testing is simpler and more efficient as the functionality improves.
Here is an example of version 4.1 documenting the unit test flow for a control
handlermappingSpring MVC uses handlermapping to find and save mapping relationships between URL requests and processing functions.Taking defaultannotationhandlermapping as an example to see the role of handlermapping in detailDefaultannotationhandlermapping will scan the @requestmapping annotations in all currently registered spring beans to find out the relation
auto-generated Method Stub
SYSTEM.OUT.PRINTLN (Exception + "-=-=--=--=-=-=-=-=-=-=-=-==-=--=-=-=-=");
}
}
Second, the definition of the Interceptor class added to the SPRINGMVC interception system1. Add the Schemaxml code that supports MVC in the SPRINGMVC configuration file
Xmlns:mvc= "Http://www.springframework.org/schema/mvc"
Xsi:schemalocation= "Http://www.springframework.org/sch
DispatcherServlet introductionDispatcherServlet is the implementation of the Spring front-end controller. It provides Spring Web MVC centralized access points and is responsible for assigning responsibilities. It is seamlessly integrated with Spring IoC containers to achieve all the benefits of Spring.DispatcherServlet
the previous articles have already covered the integration of MyBatis and Spring. But this time, all the projects are not web engineering yet, Although I have been creating Web Projects. Today will be directly integrated with MyBatis and spring mvc, The source code is downloaded at the end of this article. there are several main configurations1. Web. XML config
The previous articles have already covered the integration of MyBatis and spring. But this time, all the projects are not web engineering yet, although I have been creating Web projects. Today will be directly integrated with MyBatis and spring MVC, the source code is downloaded at the end of this article. There are several main configurations1. Web. XML config
spring4.x + Spring MVC + MYBATIS3 0 Configuration Application Development Framework (1)-Basic introduction
Two years ago has been doing the background of pure Java development, rarely involved in web development this piece, recently changed a pure Internet company, need to do a Web backend management system, before all the project with XML configuration, Contacted the company's spring4.x 0 configuration pro
initial request thread being processed is a servlet or filter in an asynchronous schedule.
Then take a look at how callable handles asynchronous operations:
Controller returns a callable instance;
Spring MVC begins to process asynchronously and commits a callable instance to taskexecutor processing in a separate thread;
Dispatcherservlet and all filter exits the request thread but res
name for the query string parameter through Http://localhost:8080/greeting?name=User.Now you notice that the message has been changed from "Hello, world!" to "Hello, user!.""Hello, user!."This change demonstrates that the @requestparam arrangement in Greetingcontroller works as expected. The name parameter has been given the default value of "World", but can always be explicitly overridden by a query string.Add a home pageStatic resources such as HTML or JavaScript or CSS can be easily provided
Now the mainstream web MVC framework, in addition to struts this main force, followed by spring MVC, so this is a programmer need to master the mainstream framework, the framework is more choice, to deal with the changing needs and business, the implementation of the program is more natural. However, to flexibly use spring
the response Controller (processor). Then, the controller interacts with my service, dao, and model layers to obtain a value, and then returns a view; then, the returned View is determined by viewResolver. The View corresponds to which the View is returned in that form, and a View is returned to it. In this way, a complete spring MVC running process is completed.
Step 3. Configure dispatcherServlet in web.
explicitly overridden through the query s Tring.Add a Home PageStatic resources, like HTML or JavaScript or CSS, can easily is served from your Spring Boot application just be dropping them into the "right place" in the source code. By default Spring Boot serves static content from resources in the classpath at "/static" (or "/public"). The index.html resource is special because it is used as a "Welcome pa
Environment constructionThe following example shows how to use the Spring MVC Framework to write a simple web-based application that can use tags to access static pages and dynamic pages. Start by using IntelliJ idea to create a dynamic Web project and follow these steps to develop a dynamic form-based Web application using the
container defaultservlet, of course, the name of the general mainstream container is not required, such as Tomcat, Jetty, JBoss, and GlassFish. If you use containers very well, you may need to specify them manually:This way is also dependent on the defaultservlet of the container, then we can directly use the container's defaultservlet to handle the static resource request, instead of first through the spring MVC
/ Spring-mvc-3.0.xsd " Below is an example of my declaration: 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/be
Spring MVC Global Exception Returns JSON exception data problem:The current project is a background support for mobile apps, developed using spring MVC + mybaits + Shiro. The backend service interacts with the phone to send JSON data. If an exception occurs in the background, it will directly return to the exception pa
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.