Detailed description of Spring mvc implementation Restful returned xml format data instance, mvcrestful
Spring mvc implements Restful to return xml format data
Recently, I want to build a Restful service interface api in my own small project. spring
Web application development based on spring MVC (3)-ResourcesThe previous article describes how spring MVC handles resource files by adding logs to a spring MVC-based Web project.Note that the dispatcherservlet of the Web. XML con
my personal drawing, there is not rigorous place, everybody deal with see. Better than nothing.
iv. Description of Dispatcherservlet
Using spring MVC, configuring Dispatcherservlet is the first step.
Dispatcherservlet is a servlet, so you can configure multiple dispatcherservlet.
Dispatcherservlet is the predecessor controller, configured in the Web.xml file. To intercept matching requests, the servle
fails.
@RequestMapping supports accessing URLs using URI templates. A URI template is like a string of URLs, consisting of one or more variable names, and when these variables have a value, it becomes a URI.
3. @PathVariable
In spring MVC, you can use the @PathVariable annotation method parameter and bind it to the value of the URI template variable. As shown in the following code:
String Findowner (str
flowchart
This picture is my personal painting, there is not rigorous place, we deal with the look. It's better than not watching.
iv. Description of Dispatcherservlet
With spring MVC, configuring Dispatcherservlet is the first step.
Dispatcherservlet is a servlet, so you can configure multiple dispatcherservlet.
The Dispatcherservlet is the predecessor controller, which is configured in the Web. xml
Original: Using IntelliJ idea to use spring MVC from zeroUsing IntelliJ idea to use spring MVC from zeroBlack Java for so many years, write an article for Java today.This article is mainly to help those who have just come into contact with Java, but also want to engage in Java WEB GUI development. For me, I had a long
The purpose of using MVC is to separate the implementation code for M and v so that the same program can use a different representation. For example, a batch of statistical data can be represented by histogram, pie chart. C exists to ensure the synchronization of M and V, and once M is changed, V should be updated synchronously.MVC is a pattern of creating WEB applications using
From:Spring MVC Flash Attribute Tutorial and usage examplesThe Spring MVC 3.1 version adds a very useful feature, the Flash attribute, which solves a problem that has long been missing a solution, a post/redirect/get pattern problem.The normal MVC Web application will post d
In the spring MVC project, you only need to put the log4j. xml file under the src/main/resources directory, and the log will work.
I still don't know which line of code is imported into the configuration file.
Example of a log4j. xml file:
Spring MVC, also known as Spring Web MVC, is a mainstream web MVC framework, similar to the STRUTS2 framework, whose main purpose is to build a full-featured MVC module for WEB applications that maps between the view layer and the
What is Spring MVC
The Spring MVC Framework is an MVC framework that separates data, business, and presentation well by implementing Model-view-controller patterns. From this perspective, Spring
dispatcherservlet mapping. Wildcard configuration is supported at the same time beanname. For example, if you configure: *.action, you can successfully access the U9controller class when you access U9vip.action.(3) The Beannameurlhandlermapping processor will look for a bean instance named "U9.action" in the Spring container. When this instance is found, the bean is used as the back-end controller to handl
Spring MVC provides an MVC-based design concept for the presentation layer, which, through a set of MVC annotations, allows ordinary Java classes to be the controller that handles requests (what the servlet does), without implementing any interfaces and supporting restful URL requests. An
;Http://www.w3.org/2001/XMLSchema-instance"Xmlns =Http://java.sun.com/xml/ns/javaee"Xsi: schemaLocation =Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"Id ="WebApp_ID"Version ="3.0">MvcCoreServlet-->MvcThe path to the configuration file defaults to/WEB-INF/Servlet-Name]-servlet. xml> example here is/WEB-INF/spring-servlet.xmlThe following is the default value -->
1.
In Tomcat, for example, to use Spirng MVC in a Web container, four items must be configured:1. Modify Web. XML,2. Add the servlet definition, write Servletname-servlet.xml (Servletname is the value of Servlet-name when configuring Dispactherservlet in Web.xm),3. Configure contextconfiglocation initialization parameters,4. Configure Contextloaderlisterner. Dispatcherservlet: Front, the class that accepts HTT
useredit.htmltemplate is used to display the user's access table list, and another userlist.html file is the user list page. All content of the template can be downloaded from the official website of the easyjf open-source team. The complete code in this example contains the template. : Http://www.easyjf.com/html/bbs/20060516/3391914101561546.htm? EJB id = 8666340670359399
3. Modify the Web. xml file as follows: the configuration file is similar to t
ModelAndView ("cat/listCat ");}}
Spring MVC does not have built-in data encapsulation. developers can encapsulate data conversion code themselves.
The unique feature of Spring MVC lies in the processing of the view layer. HandleRequestInternal returns the ModelAndView object, which can be seen as an encapsu
configuration information will be converted to the view instance managed in the Spring IoC container. beanname-viewresolver should be the initial implementation prototype!
24.4.2 viewresolver query sequence (chain of viewresolver)
Although we have always used an internalresourceviewresolver for view search in the previous example, this does not mean that each spring
class:@RestController@RequestMapping ("/classpath")public class Application {@RequestMapping ("/methodpath")Public String method () {return "mapping URL is/classpath/methodpath";}}The URL that the method methods match Is/classpath/methodpath ".TipsMultiple @controller can be defined to spread the processing of different URLs in different classesThe variable--pathvariable in the URLURLs in web apps are usually not immutable (tengyun technology ty300.com), such as two different users ' profiles f
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.