Removed Tomcat Plugin from pom.xml, rename Userdetails to User and moved

the controller to web
This commit is contained in:
vkadapa 2015-12-18 15:51:12 +05:30
parent 7fef269169
commit 5aaeb7308a
4 changed files with 64 additions and 73 deletions

View File

@ -164,14 +164,6 @@
</configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
<properties>

View File

@ -1,6 +1,6 @@
package org.baeldung.model;
public class UserDetails {
public class User {
private String firstname;
private String lastname;
private String emailId;

View File

@ -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() {

View File

@ -1,6 +1,6 @@
package org.baeldung.controller;
package org.baeldung.web.controller;
import org.baeldung.model.UserDetails;
import org.baeldung.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
@ -13,7 +13,7 @@ public class UserController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String showForm(final Model model) {
final UserDetails user = new UserDetails();
final User user = new User();
user.setFirstname("John");
user.setLastname("Roy");
user.setEmailId("John.Roy@gmail.com");
@ -22,8 +22,9 @@ public class UserController {
}
@RequestMapping(value = "/processForm", method = RequestMethod.POST)
public String processForm(@ModelAttribute(value = "user") final UserDetails user, final Model model) {
// Insert userDetails into DB
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";
}