From 5aaeb7308a3618c2f8a372c1035ac3b0d411f4a5 Mon Sep 17 00:00:00 2001 From: vkadapa Date: Fri, 18 Dec 2015 15:51:12 +0530 Subject: [PATCH] Removed Tomcat Plugin from pom.xml, rename Userdetails to User and moved the controller to web --- spring-mvc-java/pom.xml | 8 --- .../model/{UserDetails.java => User.java} | 64 +++++++++---------- .../spring/web/config/ClientWebConfig.java | 2 - .../{ => web}/controller/UserController.java | 63 +++++++++--------- 4 files changed, 64 insertions(+), 73 deletions(-) rename spring-mvc-java/src/main/java/org/baeldung/model/{UserDetails.java => User.java} (92%) rename spring-mvc-java/src/main/java/org/baeldung/{ => web}/controller/UserController.java (54%) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index a9bbf71ba3..56054b0c47 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -164,14 +164,6 @@ - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.2 - - / - - diff --git a/spring-mvc-java/src/main/java/org/baeldung/model/UserDetails.java b/spring-mvc-java/src/main/java/org/baeldung/model/User.java similarity index 92% rename from spring-mvc-java/src/main/java/org/baeldung/model/UserDetails.java rename to spring-mvc-java/src/main/java/org/baeldung/model/User.java index d0b37fae8a..df549cd21d 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/model/UserDetails.java +++ b/spring-mvc-java/src/main/java/org/baeldung/model/User.java @@ -1,32 +1,32 @@ -package org.baeldung.model; - -public class UserDetails { - private String firstname; - private String lastname; - private String emailId; - - public String getFirstname() { - return firstname; - } - - public void setFirstname(final String firstname) { - this.firstname = firstname; - } - - public String getLastname() { - return lastname; - } - - public void setLastname(final String lastname) { - this.lastname = lastname; - } - - public String getEmailId() { - return emailId; - } - - public void setEmailId(final String emailId) { - this.emailId = emailId; - } - -} +package org.baeldung.model; + +public class User { + private String firstname; + private String lastname; + private String emailId; + + public String getFirstname() { + return firstname; + } + + public void setFirstname(final String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(final String lastname) { + this.lastname = lastname; + } + + public String getEmailId() { + return emailId; + } + + public void setEmailId(final String emailId) { + this.emailId = emailId; + } + +} diff --git a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java index fe31e3581e..db57b4716b 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java +++ b/spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -6,7 +6,6 @@ import java.util.Set; import org.baeldung.dialect.CustomDialect; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Description; import org.springframework.context.support.ResourceBundleMessageSource; @@ -24,7 +23,6 @@ import org.thymeleaf.templateresolver.ServletContextTemplateResolver; @EnableWebMvc @Configuration -@ComponentScan("org.baeldung.controller") public class ClientWebConfig extends WebMvcConfigurerAdapter { public ClientWebConfig() { diff --git a/spring-mvc-java/src/main/java/org/baeldung/controller/UserController.java b/spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java similarity index 54% rename from spring-mvc-java/src/main/java/org/baeldung/controller/UserController.java rename to spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java index 3203296a17..731424c336 100644 --- a/spring-mvc-java/src/main/java/org/baeldung/controller/UserController.java +++ b/spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java @@ -1,31 +1,32 @@ -package org.baeldung.controller; - -import org.baeldung.model.UserDetails; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -@Controller -@RequestMapping("/") -public class UserController { - - @RequestMapping(value = "/", method = RequestMethod.GET) - public String showForm(final Model model) { - final UserDetails user = new UserDetails(); - user.setFirstname("John"); - user.setLastname("Roy"); - user.setEmailId("John.Roy@gmail.com"); - model.addAttribute("user", user); - return "index"; - } - - @RequestMapping(value = "/processForm", method = RequestMethod.POST) - public String processForm(@ModelAttribute(value = "user") final UserDetails user, final Model model) { - // Insert userDetails into DB - model.addAttribute("name", user.getFirstname() + " " + user.getLastname()); - return "hello"; - } - -} +package org.baeldung.web.controller; + +import org.baeldung.model.User; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@Controller +@RequestMapping("/") +public class UserController { + + @RequestMapping(value = "/", method = RequestMethod.GET) + public String showForm(final Model model) { + final User user = new User(); + user.setFirstname("John"); + user.setLastname("Roy"); + user.setEmailId("John.Roy@gmail.com"); + model.addAttribute("user", user); + return "index"; + } + + @RequestMapping(value = "/processForm", method = RequestMethod.POST) + public String processForm(@ModelAttribute(value = "user") final User user, + final Model model) { + // Insert User into DB + model.addAttribute("name", user.getFirstname() + " " + user.getLastname()); + return "hello"; + } + +}