{"id":12023,"date":"2013-04-29T16:00:09","date_gmt":"2013-04-29T13:00:09","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=12023"},"modified":"2013-04-29T05:56:07","modified_gmt":"2013-04-29T02:56:07","slug":"simple-spring-mvc-web-application-using-gradle","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html","title":{"rendered":"Simple Spring MVC Web Application using Gradle"},"content":{"rendered":"<p>This post will be similar to our previous post, <a href=\"http:\/\/codetutr.com\/2013\/03\/23\/simple-gradle-web-application\/\">Simple Gradle Web Application<\/a>, except we will now use Spring MVC, rather than raw servlets. It is really easy to get a basic Spring MVC application running with Gradle. You can download the source code for this tutorial <a title=\"Spring MVC Gradle Web App\" href=\"https:\/\/github.com\/stevehanson\/spring-mvc-simple\">on Github<\/a>.<\/p>\n<h2>Prerequisites<\/h2>\n<p><a title=\"install Gradle\" href=\"http:\/\/codetutr.com\/2013\/03\/23\/how-to-install-gradle\/\" target=\"_blank\">Install Gradle<\/a><\/p>\n<p>Our basic project structure will be:<br \/>\n&nbsp;<\/p>\n<pre class=\" brush:bash\">spring-mvc\r\n  src\r\n    main\r\n      java\r\n        com\r\n          codetutr\r\n            controller\r\n              HomeController.java\r\n            springconfig\r\n              WebConfig.java (for Java-based Spring configuration)\r\n      webapp\r\n        WEB-INF\r\n          web.xml\r\n          spring\r\n            sample-servlet.xml (for XML-based Spring configuration)\r\n          view\r\n            home.jsp<\/pre>\n<p>First, create a folder called <code>spring-mvc<\/code>, and then create the basic folder structure: src\/main\/java, src\/main\/webapp\/WEB-INF. Then, let\u2019s create the Gradle build file inside the root folder:<\/p>\n<h4><code>build.gradle<\/code><\/h4>\n<pre class=\" brush:bash\">apply plugin: 'war'\r\napply plugin: 'jetty'\r\napply plugin: 'eclipse-wtp'\r\n\r\nrepositories {\r\n   mavenCentral()\r\n}\r\n\r\ndependencies {\r\n   providedCompile 'javax.servlet:servlet-api:2.5'\r\n   compile 'org.springframework:spring-webmvc:3.2.2.RELEASE'\r\n   runtime 'javax.servlet:jstl:1.1.2'\r\n}\r\n\r\n\/* Change context path (base url). otherwise defaults to name of project *\/\r\njettyRunWar.contextPath = ''<\/pre>\n<p>Now, open your command prompt to your <code>spring-mvc<\/code> folder and run <code>gradle eclipse<\/code>. You will see gradle download all of the (many) required Spring jars that Spring-webmvc depends on. Now, import the project into Eclipse (File-&gt;Import-&gt;Existing Projects Into Workspace). Now, we will create the web.xml, Spring configuration and basic controller. The classic way to configure a Spring application is through XML configuration. As of Spring 3.1, Spring applications can also be easily configured using Java configuration (this was supported in Spring 3.0, but Spring 3.1 brought custom namespace support that really made this appealing). My preference is for Java configuration, but I will show both approaches for those who are still using XML configuration. Follow EITHER the Java configuration OR XML configuration. If you want to use XML configuration, skip this section and scroll to the XML configuration section.<\/p>\n<h2>Spring Java-Based Configuration<\/h2>\n<p>Create the <code>web.xml<\/code> file in <code>src\/main\/webapp\/WEB-INF<\/code>:<\/p>\n<h4><code>web.xml<\/code><\/h4>\n<pre class=\" brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;web-app version=\"2.5\" xmlns=\"http:\/\/java.sun.com\/xml\/ns\/javaee\"\r\nxmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\nxsi:schemaLocation=\"http:\/\/java.sun.com\/xml\/ns\/javaee http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_2_5.xsd\"&gt;\r\n\r\n  &lt;servlet&gt;\r\n    &lt;servlet-name&gt;sample&lt;\/servlet-name&gt;\r\n    &lt;servlet-class&gt;\r\n        org.springframework.web.servlet.DispatcherServlet\r\n    &lt;\/servlet-class&gt;\r\n    &lt;init-param&gt;\r\n      &lt;param-name&gt;contextClass&lt;\/param-name&gt;\r\n      &lt;param-value&gt;org.springframework.web.context.support.AnnotationConfigWebApplicationContext&lt;\/param-value&gt;\r\n    &lt;\/init-param&gt;\r\n    &lt;init-param&gt;\r\n      &lt;param-name&gt;contextConfigLocation&lt;\/param-name&gt;\r\n      &lt;param-value&gt;com.codetutr.springconfig&lt;\/param-value&gt;\r\n    &lt;\/init-param&gt;\r\n  &lt;\/servlet&gt;\r\n\r\n  &lt;servlet-mapping&gt;\r\n    &lt;servlet-name&gt;sample&lt;\/servlet-name&gt;\r\n    &lt;url-pattern&gt;\/&lt;\/url-pattern&gt;\r\n  &lt;\/servlet-mapping&gt;\r\n\r\n&lt;\/web-app&gt;<\/pre>\n<p>Notice we created a Spring DispatcherServlet mapped to all URLS \u201c\/\u201d. We also told the DispatcherServlet to look for our Java-based Spring configuration class\/es in the <code>com.codetutr.springconfig<\/code> package. Let\u2019s create our Java-configuration class, called <code>WebConfig<\/code> now in <code>com.codetutr.springconfig<\/code> package:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h4><code>WebConfig.java<\/code><\/h4>\n<pre class=\" brush:java\">package com.codetutr.springconfig;\r\n\r\nimport org.springframework.context.annotation.Bean;\r\nimport org.springframework.context.annotation.ComponentScan;\r\nimport org.springframework.context.annotation.Configuration;\r\nimport org.springframework.web.servlet.config.annotation.EnableWebMvc;\r\nimport org.springframework.web.servlet.view.InternalResourceViewResolver;\r\n\r\n@Configuration\r\n@EnableWebMvc\r\n@ComponentScan(basePackages=\"com.codetutr.controller\")\r\npublic class WebConfig {\r\n\r\n\t@Bean\r\n\tpublic InternalResourceViewResolver viewResolver() {\r\n\t\tInternalResourceViewResolver resolver = \r\n                    new InternalResourceViewResolver();\r\n\t\tresolver.setPrefix(\"\/WEB-INF\/view\/\");\r\n\t\tresolver.setSuffix(\".jsp\");\r\n\t\treturn resolver;\r\n\t}\r\n\r\n}<\/pre>\n<p>First, note the <code>@Configuration<\/code> annotation. This tells Spring that this is a configuration class (equivalent to &lt;beans&gt; XML file). Next, the <code>@EnableWebMvc<\/code> line initializes some Spring MVC magic (for converters, serializing, etc). Equivalent to <code>&lt;mvc:annotation-driven\/&gt;<\/code>.The next line with <code>@ComponentScan<\/code> tells Spring to look for classes annotated with a Spring stereotype annotation (<code>@Service, @Component, @Repository, @Controller<\/code>) \u2013 in our case, we will have some MVC controllers in the listed package. We will discuss the view resolver in a moment. Skip the following XML-based configuration section since we have already configured our application through Spring Java-Configuration.<\/p>\n<h2>Spring XML-Based Configuration (if you chose not to use Java-based above)<\/h2>\n<p>Create the <code>web.xml<\/code> file in <code>src\/main\/webapp\/WEB-INF<\/code>:<\/p>\n<h4><code>web.xml<\/code><\/h4>\n<pre class=\" brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;web-app version=\"2.5\" xmlns=\"http:\/\/java.sun.com\/xml\/ns\/javaee\"\r\nxmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\nxsi:schemaLocation=\"http:\/\/java.sun.com\/xml\/ns\/javaee http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_2_5.xsd\"&gt;\r\n\r\n  &lt;servlet&gt;\r\n    &lt;servlet-name&gt;sample&lt;\/servlet-name&gt;\r\n    &lt;servlet-class&gt;\r\n        org.springframework.web.servlet.DispatcherServlet\r\n    &lt;\/servlet-class&gt;\r\n    &lt;init-param&gt;\r\n      &lt;param-name&gt;contextConfigLocation&lt;\/param-name&gt;\r\n      &lt;param-value&gt;\/WEB-INF\/spring\/sample-servlet.xml&lt;\/param-value&gt;\r\n    &lt;\/init-param&gt;\r\n  &lt;\/servlet&gt;\r\n\r\n  &lt;servlet-mapping&gt;\r\n    &lt;servlet-name&gt;sample&lt;\/servlet-name&gt;\r\n    &lt;url-pattern&gt;\/&lt;\/url-pattern&gt;\r\n  &lt;\/servlet-mapping&gt;\r\n\r\n&lt;\/web-app&gt;<\/pre>\n<p>Notice we created a Spring DispatcherServlet mapped to all URLS \u201c\/\u201d. We also told the DispatcherServlet to look for our Spring configuration file in <code>WEB-INF\/sping\/sample-servlet.xml<\/code>. Let\u2019s create that now:<\/p>\n<h4><code>sample-servlet.xml<\/code><\/h4>\n<pre class=\" brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\r\n    xmlns:mvc=\"http:\/\/www.springframework.org\/schema\/mvc\"\r\n    xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n    xmlns:context=\"http:\/\/www.springframework.org\/schema\/context\"\r\n    xsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/beans    http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.2.xsd\r\n  http:\/\/www.springframework.org\/schema\/mvc    http:\/\/www.springframework.org\/schema\/mvc\/spring-mvc-3.2.xsd\r\n  http:\/\/www.springframework.org\/schema\/context    http:\/\/www.springframework.org\/schema\/context\/spring-context-3.2.xsd\"&gt;\r\n\r\n  &lt;context:component-scan base-package=\"com.codetutr.controller\" \/&gt;  \r\n  &lt;mvc:annotation-driven \/&gt;\r\n\r\n  &lt;bean id=\"viewResolver\" class=\"org.springframework.web.servlet.view.InternalResourceViewResolver\"&gt;\r\n    &lt;property name=\"prefix\" value=\"\/WEB-INF\/view\/\"\/&gt;\r\n    &lt;property name=\"suffix\" value=\".jsp\"\/&gt;\r\n  &lt;\/bean&gt;\r\n\r\n&lt;\/beans&gt;<\/pre>\n<p>The first line, with <code>context:component-scan<\/code> tells Spring to look for classes annotated with a Spring stereotype annotation (<code>@Service, @Component, @Repository, @Controller<\/code>). <code>&lt;mvc:annotation-driven \/&gt;<\/code> tells Spring to add some MVC goodies. We will discuss the view resolver in a moment.<\/p>\n<h2>Build a controller (Everyone do this \u2013 same for XML and Java configuration)<\/h2>\n<p>Now that we have told Spring to look for MVC controllers in our <code>com.codetutr.controller<\/code> package, let\u2019s build a simple controller. Create a new class in <code>com.codetutr.controller<\/code> package, called <code>SampleController<\/code>. Type in the following contents:<\/p>\n<h4><code>SampleController.java<\/code><\/h4>\n<pre class=\" brush:java\">package com.codetutr.controller;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.ui.Model;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\n\r\n@Controller\r\npublic class SampleController {\r\n\r\n\t@RequestMapping(\"home\")\r\n\tpublic String loadHomePage(Model m) {\r\n\t\tm.addAttribute(\"name\", \"CodeTutr\");\r\n\t\treturn \"home\";\r\n\t}\r\n}<\/pre>\n<p>Remember when we created the <code>viewResolver<\/code> bean in the <code>sample-servlet.xml<\/code> Spring configuration file? We set the prefix as <code>WEB-INF\/view<\/code> and the suffix as <code>.jsp<\/code>. Using this resolver, after the above method executes with return value <code>home<\/code>, Spring will look for a file called <code>WEB-INF\/view\/home.jsp<\/code> to render the view. Let\u2019s create that file now:<\/p>\n<h4><code>home.jsp<\/code><\/h4>\n<pre class=\" brush:xml\">&lt;!DOCTYPE HTML&gt;\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;Sample Application&lt;\/title&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n\t&lt;h1&gt;Hello, ${name}!&lt;\/h1&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>That\u2019s it! You now have a basic Spring-MVC application set up. Open your command prompt to the root of the project directory and type <code>gradle jettyRunWar<\/code>. This will launch an embedded Jetty Server at port 8080. Navigate to <a href=\"http:\/\/localhost:8080\/spring-mvc\/home\">http:\/\/localhost:8080\/home<\/a> and you should see:<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/04\/Screen-Shot-2013-04-12-at-10.31.57-PM.png\"><img decoding=\"async\" class=\"aligncenter\" alt=\"\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/04\/Screen-Shot-2013-04-12-at-10.31.57-PM.png\" width=\"550\" height=\"334\" \/><\/a><\/p>\n<p>Now that you have a basic Spring MVC application running, follow the <a title=\"Spring MVC Form Tutorial\" href=\"http:\/\/codetutr.com\/2013\/04\/06\/spring-mvc-form-submission\/\">Spring MVC Form Submission tutorial<\/a>.<\/p>\n<p><strong>Full Source:<\/strong>\u00a0<a title=\"Spring MVC Simple ZIP\" href=\"https:\/\/github.com\/stevehanson\/spring-mvc-simple\/archive\/master.zip\">ZIP<\/a>,\u00a0<a title=\"GitHub Full Source\" href=\"https:\/\/github.com\/stevehanson\/spring-mvc-simple\" target=\"_blank\">GitHub<\/a><br \/>\nTo run the code from this tutorial: Must have\u00a0<a title=\"How to install Gradle\" href=\"http:\/\/codetutr.com\/2013\/03\/23\/how-to-install-gradle\/\">Gradle installed<\/a>. Download the ZIP. Extract. Open command prompt to extracted location. Run gradle jettyRunWar. Navigate in browser to http:\/\/localhost:8080\/home.<\/p>\n<h4>Resources<\/h4>\n<p><a href=\"http:\/\/blog.springsource.org\/2011\/02\/21\/spring-3-1-m1-mvc-namespace-enhancements-and-configuration\/\" target=\"_blank\">SpringSource Blog \u2013 MVC Namespace Enhancements and Configuration<\/a><br \/>\n<a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.1.x\/javadoc-api\/org\/springframework\/web\/servlet\/config\/annotation\/EnableWebMvc.html\" target=\"_blank\">SpringSource Docs \u2013 EnableWebMvc Documentation<\/a><br \/>\n&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/codetutr.com\/2013\/03\/24\/simple-spring-mvc-web-application-using-gradle\/\">Simple Spring MVC Web Application using Gradle<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Steve Hanson at the <a href=\"http:\/\/codetutr.com\/\">CodeTutr<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This post will be similar to our previous post, Simple Gradle Web Application, except we will now use Spring MVC, rather than raw servlets. It is really easy to get a basic Spring MVC application running with Gradle. You can download the source code for this tutorial on Github. Prerequisites Install Gradle Our basic project &hellip;<\/p>\n","protected":false},"author":409,"featured_media":129,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[484,30,150],"class_list":["post-12023","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-gradle","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>Simple Spring MVC Web Application using Gradle<\/title>\n<meta name=\"description\" content=\"This post will be similar to our previous post, Simple Gradle Web Application, except we will now use Spring MVC, rather than raw servlets. It is really\" \/>\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\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Simple Spring MVC Web Application using Gradle\" \/>\n<meta property=\"og:description\" content=\"This post will be similar to our previous post, Simple Gradle Web Application, except we will now use Spring MVC, rather than raw servlets. It is really\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.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=\"2013-04-29T13:00:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/gradle-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=\"Steve Hanson\" \/>\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=\"Steve Hanson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html\"},\"author\":{\"name\":\"Steve Hanson\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/006867093496e3253c65f37b3fbec162\"},\"headline\":\"Simple Spring MVC Web Application using Gradle\",\"datePublished\":\"2013-04-29T13:00:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html\"},\"wordCount\":660,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/gradle-logo.jpg\",\"keywords\":[\"Gradle\",\"Spring\",\"Spring MVC\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html\",\"name\":\"Simple Spring MVC Web Application using Gradle\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/gradle-logo.jpg\",\"datePublished\":\"2013-04-29T13:00:09+00:00\",\"description\":\"This post will be similar to our previous post, Simple Gradle Web Application, except we will now use Spring MVC, rather than raw servlets. It is really\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/gradle-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/gradle-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/simple-spring-mvc-web-application-using-gradle.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\":\"Simple Spring MVC Web Application using Gradle\"}]},{\"@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\\\/006867093496e3253c65f37b3fbec162\",\"name\":\"Steve Hanson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5f329aad08233a668ee56ee53f005a94376612b242454cfefaf060b5d6474de0?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5f329aad08233a668ee56ee53f005a94376612b242454cfefaf060b5d6474de0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5f329aad08233a668ee56ee53f005a94376612b242454cfefaf060b5d6474de0?s=96&d=mm&r=g\",\"caption\":\"Steve Hanson\"},\"description\":\"Steve is a software developer interested in web development and new technologies. He currently works as a Java consultant at Credera in Dallas, TX.\",\"sameAs\":[\"http:\\\/\\\/codetutr.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/steve-hanson\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Simple Spring MVC Web Application using Gradle","description":"This post will be similar to our previous post, Simple Gradle Web Application, except we will now use Spring MVC, rather than raw servlets. It is really","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\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html","og_locale":"en_US","og_type":"article","og_title":"Simple Spring MVC Web Application using Gradle","og_description":"This post will be similar to our previous post, Simple Gradle Web Application, except we will now use Spring MVC, rather than raw servlets. It is really","og_url":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-04-29T13:00:09+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/gradle-logo.jpg","type":"image\/jpeg"}],"author":"Steve Hanson","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Steve Hanson","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html"},"author":{"name":"Steve Hanson","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/006867093496e3253c65f37b3fbec162"},"headline":"Simple Spring MVC Web Application using Gradle","datePublished":"2013-04-29T13:00:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html"},"wordCount":660,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/gradle-logo.jpg","keywords":["Gradle","Spring","Spring MVC"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html","url":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html","name":"Simple Spring MVC Web Application using Gradle","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/gradle-logo.jpg","datePublished":"2013-04-29T13:00:09+00:00","description":"This post will be similar to our previous post, Simple Gradle Web Application, except we will now use Spring MVC, rather than raw servlets. It is really","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/gradle-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/gradle-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/simple-spring-mvc-web-application-using-gradle.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":"Simple Spring MVC Web Application using Gradle"}]},{"@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\/006867093496e3253c65f37b3fbec162","name":"Steve Hanson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5f329aad08233a668ee56ee53f005a94376612b242454cfefaf060b5d6474de0?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5f329aad08233a668ee56ee53f005a94376612b242454cfefaf060b5d6474de0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5f329aad08233a668ee56ee53f005a94376612b242454cfefaf060b5d6474de0?s=96&d=mm&r=g","caption":"Steve Hanson"},"description":"Steve is a software developer interested in web development and new technologies. He currently works as a Java consultant at Credera in Dallas, TX.","sameAs":["http:\/\/codetutr.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/steve-hanson"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/12023","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\/409"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=12023"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/12023\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/129"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=12023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=12023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=12023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}