{"id":75907,"date":"2018-04-17T01:00:15","date_gmt":"2018-04-16T22:00:15","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=75907"},"modified":"2023-12-11T10:49:03","modified_gmt":"2023-12-11T08:49:03","slug":"spring-mvc-tutorial-2","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html","title":{"rendered":"Spring MVC Tutorial"},"content":{"rendered":"<h2>1. Introduction<\/h2>\n<p>As an <a href=\"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java\" target=\"_blank\" rel=\"noopener\">Enterprise Java<\/a> Developer, one of the main focus in the job is developing web applications. With a web application, many challenges also come into the picture as consequences. To be specific, some of these are state management, workflow and validations. The HTTP protocol&#8217;s stateless nature only make things more complex. The Spring&#8217;s web framework is designed to help us in these challenges. Based on the Model-View-Controller (MVC) pattern, Spring MVC helps us to build applications which are very loosely coupled and flexible, even after we take care of all the challenges presented by HTTP protocol and other.<\/p>\n<p>In this lesson, we will start by understanding the purpose of each of the Spring MVC Component and the role they play in handling request and response objects throughout their life in a Spring application. After this, we will start configuring a simple Spring MVC application, adding a component at each step, writing a very simple Thymeleaf template and finally including a <a href=\"https:\/\/www.javacodegeeks.com\/2014\/11\/junit-tutorial-unit-testing.html\" target=\"_blank\" rel=\"noopener\">JUnit<\/a> test case for the Controller we write. Let&#8217;s get started!<\/p>\n<h2>2. Life of a Request<\/h2>\n<p><figure id=\"attachment_75918\" aria-describedby=\"caption-attachment-75918\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/request-life.png\"><img decoding=\"async\" class=\"wp-image-75918\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/request-life.png\" alt=\"Life of Request Object\" width=\"820\" height=\"423\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/request-life.png 860w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/request-life-300x155.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/request-life-768x397.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-75918\" class=\"wp-caption-text\">Life of Request Object<\/figcaption><\/figure><\/p>\n<p>As soon as a user on the web clicks on a link on an HTML page, work of a request object starts. When a request object leaves the browser and enters into a Spring MVC application which finally transforms into a response object, it makes several stops to provide some information to the MVC Components and get loaded with some new information. The above image shows all the stops the request object makes before it is transformed into a response object.<\/p>\n<p>Let us understand what all steps do a request object takes in a Spring MVC application:<\/p>\n<ol>\n<li>The request first arrives at the <code>DispatcherServlet<\/code> which acts as a <strong>Front Controller and delegates responsibility<\/strong> to other components of the framework to do the processing. To identify the Controller where a request should be sent, <code>DispatcherServlet<\/code> consults the Handler Mappings which extract the URL from the request object and finds the appropriate Controller for this request.<\/li>\n<li>Once a request reaches a Controller, it drops all information it has and patiently waits for Controller to perform his processing. Usually, Controller provides a model and a view name which provides the HTML content for the response.<\/li>\n<li>To keep things decoupled between a Controller and views, Controller only returns the logical view name as a String to the <code>DispatcherServlet<\/code>. <code>DispatcherServlet <\/code> then consults a View Resolver to map this String logical view name to a specific view implementation which can be a JSP page or an HTML page.<\/li>\n<li>After <code>DispatcherServlet <\/code>knows which View to render, it finally sends the model data to the actual view so that a response object can be constructed. Now, the life of the request object is over.<\/li>\n<li>This View is now converted to a response object and sent back to the user where it can be shown in a browser.<\/li>\n<\/ol>\n<p>Sounds like all the work was done by request object and the user only sees the response object. That&#8217;s true!<\/p>\n<h2>3. Project Setup<\/h2>\n<p>We will be using one of the many Maven archetypes to create a sample project for our example. To create the project execute the following command in a directory that you will use as workspace:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Create project<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mvn archetype:generate -DgroupId=com.javacodegeeks.example -DartifactId=JCG-SpringMVC-example -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false\n<\/pre>\n<p>If you are running maven for the first time, it will take a few seconds to accomplish the generate command because maven has to download all the required plugins and artifacts in order to make the generation task.<\/p>\n<p><figure id=\"attachment_76005\" aria-describedby=\"caption-attachment-76005\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/maven-project-created-2.png\"><img decoding=\"async\" class=\"wp-image-76005\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/maven-project-created-2.png\" alt=\"Creating Project with Maven\" width=\"820\" height=\"501\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/maven-project-created-2.png 861w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/maven-project-created-2-300x183.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/maven-project-created-2-768x469.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-76005\" class=\"wp-caption-text\">Creating Project with Maven<\/figcaption><\/figure><\/p>\n<p>Once you have created the project, feel free to open it in your favourite IDE. Next step is to add appropriate Maven Dependencies to the project.<\/p>\n<p>Here is the <code>pom.xml<\/code> file with the appropriate dependencies:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n  xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/maven-v4_0_0.xsd\"&gt;\n  &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n\n  &lt;groupId&gt;com.javacodegeeks.example&lt;\/groupId&gt;\n  &lt;artifactId&gt;JCG-SpringMVC-example&lt;\/artifactId&gt;\n  &lt;version&gt;1.0-SNAPSHOT&lt;\/version&gt;\n  &lt;name&gt;JCG-SpringMVC-example&lt;\/name&gt;\n  &lt;packaging&gt;war&lt;\/packaging&gt;\n  &lt;description&gt;Spring MVC Hello World Example&lt;\/description&gt;\n\n  &lt;dependencies&gt;\n\n    &lt;!--Spring MVC Dependencies--&gt;\n    &lt;dependency&gt;\n      &lt;groupId&gt;org.springframework&lt;\/groupId&gt;\n      &lt;artifactId&gt;spring-webmvc&lt;\/artifactId&gt;\n      &lt;version&gt;4.3.9.RELEASE&lt;\/version&gt;\n    &lt;\/dependency&gt;\n    &lt;dependency&gt;\n      &lt;groupId&gt;org.springframework&lt;\/groupId&gt;\n      &lt;artifactId&gt;spring-web&lt;\/artifactId&gt;\n      &lt;version&gt;4.3.9.RELEASE&lt;\/version&gt;\n    &lt;\/dependency&gt;\n\n    &lt;!-- Servlet --&gt;\n    &lt;dependency&gt;\n      &lt;groupId&gt;javax.servlet&lt;\/groupId&gt;\n      &lt;artifactId&gt;servlet-api&lt;\/artifactId&gt;\n      &lt;version&gt;2.5&lt;\/version&gt;\n      &lt;scope&gt;provided&lt;\/scope&gt;\n    &lt;\/dependency&gt;\n    &lt;dependency&gt;\n      &lt;groupId&gt;javax.servlet.jsp&lt;\/groupId&gt;\n      &lt;artifactId&gt;jsp-api&lt;\/artifactId&gt;\n      &lt;version&gt;2.1&lt;\/version&gt;\n      &lt;scope&gt;provided&lt;\/scope&gt;\n    &lt;\/dependency&gt;\n    &lt;dependency&gt;\n      &lt;groupId&gt;javax.servlet&lt;\/groupId&gt;\n      &lt;artifactId&gt;jstl&lt;\/artifactId&gt;\n      &lt;version&gt;1.2&lt;\/version&gt;\n    &lt;\/dependency&gt;\n\n  &lt;\/dependencies&gt;\n\n  &lt;build&gt;\n    &lt;plugins&gt;\n      &lt;plugin&gt;\n        &lt;artifactId&gt;maven-compiler-plugin&lt;\/artifactId&gt;\n        &lt;version&gt;3.6.1&lt;\/version&gt;\n        &lt;configuration&gt;\n          &lt;source&gt;1.8&lt;\/source&gt;\n          &lt;target&gt;1.8&lt;\/target&gt;\n        &lt;\/configuration&gt;\n      &lt;\/plugin&gt;\n      &lt;plugin&gt;\n        &lt;artifactId&gt;maven-war-plugin&lt;\/artifactId&gt;\n        &lt;version&gt;3.0.0&lt;\/version&gt;\n        &lt;configuration&gt;\n          &lt;warSourceDirectory&gt;WebContent&lt;\/warSourceDirectory&gt;\n        &lt;\/configuration&gt;\n      &lt;\/plugin&gt;\n    &lt;\/plugins&gt;\n    &lt;!-- added to remove Version from WAR file --&gt;\n    &lt;finalName&gt;${project.artifactId}&lt;\/finalName&gt;\n  &lt;\/build&gt;\n&lt;\/project&gt;\n<\/pre>\n<p>Finally, to understand all the JARs which are added to the project when we added this dependency, we can run a simple Maven command which allows us to see a complete Dependency Tree for a project when we add some dependencies to it. Here is a command which we can use:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><span style=\"text-decoration: underline;\"><em>Dependency Tree<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mvn dependency:tree\n<\/pre>\n<p>When we run this command, it will show us the following Dependency Tree:<\/p>\n<p><figure id=\"attachment_75924\" aria-describedby=\"caption-attachment-75924\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/dependency-tree.png\"><img decoding=\"async\" class=\"wp-image-75924\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/dependency-tree.png\" alt=\"Spring MVC Project Dependency Tree\" width=\"820\" height=\"436\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/dependency-tree.png 860w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/dependency-tree-300x160.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/dependency-tree-768x408.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/dependency-tree-620x330.png 620w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-75924\" class=\"wp-caption-text\">Spring MVC Project Dependency Tree<\/figcaption><\/figure><\/p>\n<h2>4. Configuring DispatcherServlet<\/h2>\n<p>As we expressed in the last section, everything starts at <code>DispatcherServlet<\/code>. So, this will be the first component we will be adding to our project. Note that instead of a <code>web.xml<\/code> file, we will configuring <code>DispatcherServlet <\/code>in a Java class:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>AppInitializer.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example.config;\n\nimport org.springframework.web.servlet.support.\n        AbstractAnnotationConfigDispatcherServletInitializer;\n\npublic class AppInitializer extends\n        AbstractAnnotationConfigDispatcherServletInitializer {\n\n    @Override\n    protected Class&lt;?&gt;[] getRootConfigClasses() {\n        return new Class[] { RootConfig.class };\n    }\n\n    @Override\n    protected Class&lt;?&gt;[] getServletConfigClasses() {\n        return new Class[] { WebConfig.class };\n    }\n\n    @Override\n    protected String[] getServletMappings() {\n        return new String[] { \"\/\" };\n    }\n}\n<\/pre>\n<p>The first thing to notice here is that any class which extends <code>AbstractAnnotationConfigDispatcherServletInitializer<\/code> will be used to configure the <code>DispatcherServlet <\/code>and the application context.<\/p>\n<p>The method <code>getServletMappings()<\/code> identifies the path where the <code>DispatcherServlet<\/code> will be mapped to. Here, as we provided a <code>\/<\/code>, it will be the application&#8217;s default servlet. When the <code>DispatcherServlet <\/code>starts up, it creates Spring application context and starts loading it with beans declared in the <code>WebConfig<\/code> class which is defined by the <code>getServletConfigClasses()<\/code> method. Finally, the classes returned by <code>getRootConfigClasses()<\/code> method is used to load the context created by <code>ContextLoaderlistener<\/code>.<\/p>\n<p>Let&#8217;s define the <code>WebConfig<\/code> and <code>RootConfig<\/code> classes now and see what their functions are.<\/p>\n<h2>5. Enabling Web MVC<\/h2>\n<p>One of the classic ways to enable Spring MVC Components is to use XML files with <code><\/code> elements. But in this lesson, we will show the latest way to provide all configuration using Java classes only. Let us enable Spring MVC Components by defining our <code>WebConfig<\/code> class:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>WebConfig.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example.config;\n\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.ComponentScan;\nimport org.springframework.context.annotation.Configuration;\nimport org.springframework.web.servlet.ViewResolver;\nimport org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;\nimport org.springframework.web.servlet.config.annotation.EnableWebMvc;\nimport org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;\nimport org.springframework.web.servlet.view.InternalResourceViewResolver;\n\n@Configuration\n@EnableWebMvc\n@ComponentScan(\"com.javacodegeeks.example\")\npublic class WebConfig extends WebMvcConfigurerAdapter {\n    \n    @Bean\n    public ViewResolver viewResolver() {\n        InternalResourceViewResolver viewResolver = \n                new InternalResourceViewResolver();\n        viewResolver.setPrefix(\"\/WEB-INF\/views\/\");\n        viewResolver.setSuffix(\".jsp\");\n        viewResolver.setExposeContextBeansAsAttributes(true);\n        return viewResolver;\n    }\n\n    @Override\n    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {\n        configurer.enable();\n    }\n}\n<\/pre>\n<p>A lot of things happened in this configuration class. Let&#8217;s understand each of those things:<\/p>\n<ul>\n<li>The first thing we did is annotating the class with <code>@ComponentScan<\/code>. This tells Spring which package to scan to find the Spring Beans and components we define. It will parse all child packages as well in the mentioned package.<\/li>\n<li>We also define a <code>ViewResolver<\/code> bean on the class and we configure it to look for JSP pages in a specified location relatively to the classpath for the application.<\/li>\n<li>Finally, this class extends <code>WebMvcConfigurerAdapter<\/code> and overrides the <code>configureDefaultServletHandling<\/code> method and calls <code>enable()<\/code> on the configurer object which tells the <code>DispatcherServlet <\/code>to forward the request for static resources to <code>ViewResolver<\/code> and don&#8217;t handle them yourself.<\/li>\n<\/ul>\n<h2>6. Defining Root Config<\/h2>\n<p>For the application context beans in a <code>ContextLoaderlistener<\/code>, we won&#8217;t be defining any beans. In a <code>RootConfig<\/code> class, we can even define the beans for non-web components. Let&#8217;s take a look at the sample code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>RootConfig.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example.config;\n\nimport org.springframework.context.annotation.ComponentScan;\nimport org.springframework.context.annotation.Configuration;\nimport org.springframework.context.annotation.FilterType;\nimport org.springframework.web.servlet.config.annotation.EnableWebMvc;\n\n@Configuration\n@ComponentScan(basePackages = {\"com.javacodegeeks.example\"},\n        excludeFilters = {\n                @ComponentScan.Filter(type = FilterType.ANNOTATION, value = EnableWebMvc.class)\n        })\npublic class RootConfig {\n}\n<\/pre>\n<p>The only thing we did is annotating the class with <code>@ComponentScan<\/code>. This tells Spring which package to scan to find the non-web components which might exist in the project.<br \/>\n[ulp id=&#8217;oiCtu6x3AwpaVNPI&#8217;]<br \/>\n&nbsp;<\/p>\n<h2>7. Writing a Simple Controller<\/h2>\n<p>Things start to get interesting when we define a component which allows an end-user to interact with the applications we create. A controller is a component which provides mapping in the form of URLs which a user can interact with to get some response. In this example, we will create a single GET Request mapping which just returns the logical view name of a view which is then resolved to a JSP by the configured View Resolver we create. Let&#8217;s look at the sample controller we created:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>HomeController.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example.controller;\n\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\n\n@Controller\npublic class HomeController {\n\n    @RequestMapping(value = \"\/\", method = RequestMethod.GET)\n    public String home() {\n        return \"home\";\n    }\n}\n<\/pre>\n<p>We defined a single GET Mapping here which just returns the logical view name i.e. <code>home<\/code>. This will be resolved to the path <code>\/WebContent\/WEB-INF\/views\/home.jsp<\/code>.<\/p>\n<h2>8. Designing a View<\/h2>\n<p>For a JSP view, we will design a very simple JSP page which will just present sample design. We created this file from the application root and on the path <code>\/WebContent\/WEB-INF\/views\/home.jsp<\/code>. Here is the file:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>home.jsp<\/em><\/span><\/p>\n<pre class=\"brush:html\">&lt;%@ taglib uri=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" prefix=\"c\" %&gt;\n&lt;%@ page session=\"false\" %&gt;\n&lt;html&gt;\n    &lt;head&gt;\n        &lt;title&gt;JavaCodeGeeks: Spring MVC&lt;\/title&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n        &lt;h1&gt;Welcome Spring MVC&lt;\/h1&gt;\n        &lt;p&gt;Hello JavaCodeGeeks!&lt;\/p&gt;\n    &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p>To see what we have made, we will be running our application next. Note that this is just a basic JSP page and nothing else to present how the <code>ViewResolver <\/code> resolves a logical view name into a concrete view which <code>DispatcherServlet <\/code> returns as a response.<\/p>\n<h2>9. Running the Application<\/h2>\n<p>It&#8217;s time we run our application. We use IntelliJ IDE to run the project. To run the project, first configure the Tomcat to accept an exploded WAR artifact:<\/p>\n<p><figure id=\"attachment_75929\" aria-describedby=\"caption-attachment-75929\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/tomcat-configuration.png\"><img decoding=\"async\" class=\"wp-image-75929\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/tomcat-configuration.png\" alt=\"Tomcat Configuration with exploded WAR\" width=\"820\" height=\"600\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/tomcat-configuration.png 860w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/tomcat-configuration-300x219.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/tomcat-configuration-768x562.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-75929\" class=\"wp-caption-text\">Tomcat Configuration with exploded WAR<\/figcaption><\/figure><\/p>\n<p>Finally, when we run our application, we can see the output from the JSP view we created:<\/p>\n<p><figure id=\"attachment_75930\" aria-describedby=\"caption-attachment-75930\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/app-output.png\"><img decoding=\"async\" class=\"wp-image-75930\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/app-output.png\" alt=\"Running Spring MVC Application\" width=\"820\" height=\"375\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/app-output.png 860w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/app-output-300x137.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/app-output-768x351.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-75930\" class=\"wp-caption-text\">Running Spring MVC Application<\/figcaption><\/figure><\/p>\n<h2>10. Spring MVC with Spring Boot<\/h2>\n<p><a href=\"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-boot-tutorial.html\" target=\"_blank\" rel=\"noopener\">Spring Boot<\/a> is an excellent platform which is built atop the Spring MVC Framework and makes things a lot faster and easy. This ease is created by using many default settings and configurations related to the dependencies we add to our project. Another advantage Spring Boot offers is that it allows us to define a parent dependency through which version compatibility is maintained across the project. Let&#8217;s take a look at this in detail.<\/p>\n<h3>10.1 Spring Boot Starters<\/h3>\n<p>Spring Boot provides very convenient <strong>starter dependencies<\/strong> which allows us to select a functionality and add a dependency related to it to our project. Once that is done, Spring Boot itself manages and bring all related dependencies into our project with a correct version number with a guarantee that these dependencies will be compatible with each other. The parent dependency is defined as:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Starter Dependency<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;parent&gt;\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\n    &lt;version&gt;1.5.6.RELEASE&lt;\/version&gt;\n&lt;\/parent&gt;\n<\/pre>\n<p>When you provide a <code>version<\/code> here and use the same <code>groupId<\/code> in <code>dependencies<\/code> section in <code>pom.xml<\/code> file, version will be automatically imported.<\/p>\n<h3>10.2 Staring Spring Boot applications<\/h3>\n<p>Each Spring Boot application is provided an entry point in the form of same old <code>main()<\/code> method. We can run this method just like a normal main method which takes care of initialising the Spring Beans and starting the app. The most common form of the Spring Boot main class can be shown here:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Spring Boot Main class<\/em><\/span><\/p>\n<pre class=\"brush:java\">@SpringBootApplication\npublic class JCGApplication {\n    public static void main(String[] args) {\n        SpringApplication.run(JCGApplication.class, args);\n    }\n}\n<\/pre>\n<p>With a single annotation of <code>@SpringBootApplication<\/code>, we have enabled the following annotations:<\/p>\n<ul>\n<li><code>@Configuration<\/code>: This annotation marks this class a Configuration class and is initialised first by Spring Container<\/li>\n<li><code>@EnableAutoConfiguration<\/code>: This annotation implied that every class marked with annotations like <code>@Component<\/code> and related will be loaded as a Spring Bean<\/li>\n<li><code>@ComponentScan<\/code>: Finally, this annotation will enable the component scan automatically. By default, when we do not provide any package value, this annotation will pick the package this class resides and start looking for Spring components from there.<\/li>\n<\/ul>\n<p>Look at how easy other things are made with <a href=\"https:\/\/www.javacodegeeks.com\/2017\/01\/spring-boot-right-boot.html\" target=\"_blank\" rel=\"noopener\">Spring Boot here<\/a>.<\/p>\n<h2>11. Conclusion<\/h2>\n<p>In this lesson, we understood what happens when a request object leaves a web browser and how it gets transformed to a response object. This post also explains what an important role does a <code>DispatcherServlet<\/code> play while processing a request from a client. We also made a simple Spring MVC application to see how view names are resolved into concrete view implementations as well.<\/p>\n<p>It is important to understand that even though <a href=\"https:\/\/www.javacodegeeks.com\/2017\/01\/spring-boot-right-boot.html\" target=\"_blank\" rel=\"noopener\">Spring Boot<\/a> has evolved Spring into a much simpler workspace, it still relies on Spring MVC to provide default settings and beans.<\/p>\n<h2>12. Download the Source Code<\/h2>\n<p>This was an example of simple Spring MVC application.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <strong><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/04\/JCG-SpringMVC-example.zip\" target=\"_blank\" rel=\"noopener\">JCG-SpringMVC-example<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction As an Enterprise Java Developer, one of the main focus in the job is developing web applications. With a web application, many challenges also come into the picture as consequences. To be specific, some of these are state management, workflow and validations. The HTTP protocol&#8217;s stateless nature only make things more complex. The &hellip;<\/p>\n","protected":false},"author":20016,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30,150],"class_list":["post-75907","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-spring","tag-spring-mvc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring MVC Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"1. Introduction As an Enterprise Java Developer, one of the main focus in the job is developing web applications. With a web application, many challenges\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring MVC Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"1. Introduction As an Enterprise Java Developer, one of the main focus in the job is developing web applications. With a web application, many challenges\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-16T22:00:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-11T08:49:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shubham Aggarwal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shubham Aggarwal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html\"},\"author\":{\"name\":\"Shubham Aggarwal\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/0953481a8babbb7a63907edb41f357ad\"},\"headline\":\"Spring MVC Tutorial\",\"datePublished\":\"2018-04-16T22:00:15+00:00\",\"dateModified\":\"2023-12-11T08:49:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html\"},\"wordCount\":1798,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Spring\",\"Spring MVC\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html\",\"name\":\"Spring MVC Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2018-04-16T22:00:15+00:00\",\"dateModified\":\"2023-12-11T08:49:03+00:00\",\"description\":\"1. Introduction As an Enterprise Java Developer, one of the main focus in the job is developing web applications. With a web application, many challenges\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/04\\\/spring-mvc-tutorial-2.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring MVC Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/0953481a8babbb7a63907edb41f357ad\",\"name\":\"Shubham Aggarwal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"caption\":\"Shubham Aggarwal\"},\"description\":\"Shubham is a Java EE Engineer with about 3 years of experience in building quality products with Spring Boot, Spring Data, AWS, Kafka, PrestoDB.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sbmaggarwal\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/shubham-aggarwal\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring MVC Tutorial - Java Code Geeks","description":"1. Introduction As an Enterprise Java Developer, one of the main focus in the job is developing web applications. With a web application, many challenges","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html","og_locale":"en_US","og_type":"article","og_title":"Spring MVC Tutorial - Java Code Geeks","og_description":"1. Introduction As an Enterprise Java Developer, one of the main focus in the job is developing web applications. With a web application, many challenges","og_url":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-04-16T22:00:15+00:00","article_modified_time":"2023-12-11T08:49:03+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Shubham Aggarwal","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Shubham Aggarwal","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html"},"author":{"name":"Shubham Aggarwal","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/0953481a8babbb7a63907edb41f357ad"},"headline":"Spring MVC Tutorial","datePublished":"2018-04-16T22:00:15+00:00","dateModified":"2023-12-11T08:49:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html"},"wordCount":1798,"commentCount":3,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Spring","Spring MVC"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html","url":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html","name":"Spring MVC Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2018-04-16T22:00:15+00:00","dateModified":"2023-12-11T08:49:03+00:00","description":"1. Introduction As an Enterprise Java Developer, one of the main focus in the job is developing web applications. With a web application, many challenges","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2018\/04\/spring-mvc-tutorial-2.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring MVC Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/0953481a8babbb7a63907edb41f357ad","name":"Shubham Aggarwal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","caption":"Shubham Aggarwal"},"description":"Shubham is a Java EE Engineer with about 3 years of experience in building quality products with Spring Boot, Spring Data, AWS, Kafka, PrestoDB.","sameAs":["https:\/\/www.linkedin.com\/in\/sbmaggarwal\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/shubham-aggarwal"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/75907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/20016"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=75907"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/75907\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=75907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=75907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=75907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}