Skip to content

Commit 5aaeb73

Browse files
committed
Removed Tomcat Plugin from pom.xml, rename Userdetails to User and moved
the controller to web
1 parent 7fef269 commit 5aaeb73

File tree

4 files changed

+64
-73
lines changed

4 files changed

+64
-73
lines changed

spring-mvc-java/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,6 @@
164164
</configuration>
165165
</configuration>
166166
</plugin>
167-
<plugin>
168-
<groupId>org.apache.tomcat.maven</groupId>
169-
<artifactId>tomcat7-maven-plugin</artifactId>
170-
<version>2.2</version>
171-
<configuration>
172-
<path>/</path>
173-
</configuration>
174-
</plugin>
175167
</plugins>
176168
</build>
177169
<properties>

spring-mvc-java/src/main/java/org/baeldung/model/UserDetails.java renamed to spring-mvc-java/src/main/java/org/baeldung/model/User.java

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
package org.baeldung.model;
2-
3-
public class UserDetails {
4-
private String firstname;
5-
private String lastname;
6-
private String emailId;
7-
8-
public String getFirstname() {
9-
return firstname;
10-
}
11-
12-
public void setFirstname(final String firstname) {
13-
this.firstname = firstname;
14-
}
15-
16-
public String getLastname() {
17-
return lastname;
18-
}
19-
20-
public void setLastname(final String lastname) {
21-
this.lastname = lastname;
22-
}
23-
24-
public String getEmailId() {
25-
return emailId;
26-
}
27-
28-
public void setEmailId(final String emailId) {
29-
this.emailId = emailId;
30-
}
31-
32-
}
1+
package org.baeldung.model;
2+
3+
public class User {
4+
private String firstname;
5+
private String lastname;
6+
private String emailId;
7+
8+
public String getFirstname() {
9+
return firstname;
10+
}
11+
12+
public void setFirstname(final String firstname) {
13+
this.firstname = firstname;
14+
}
15+
16+
public String getLastname() {
17+
return lastname;
18+
}
19+
20+
public void setLastname(final String lastname) {
21+
this.lastname = lastname;
22+
}
23+
24+
public String getEmailId() {
25+
return emailId;
26+
}
27+
28+
public void setEmailId(final String emailId) {
29+
this.emailId = emailId;
30+
}
31+
32+
}

spring-mvc-java/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.baeldung.dialect.CustomDialect;
77
import org.springframework.context.MessageSource;
88
import org.springframework.context.annotation.Bean;
9-
import org.springframework.context.annotation.ComponentScan;
109
import org.springframework.context.annotation.Configuration;
1110
import org.springframework.context.annotation.Description;
1211
import org.springframework.context.support.ResourceBundleMessageSource;
@@ -24,7 +23,6 @@
2423

2524
@EnableWebMvc
2625
@Configuration
27-
@ComponentScan("org.baeldung.controller")
2826
public class ClientWebConfig extends WebMvcConfigurerAdapter {
2927

3028
public ClientWebConfig() {

spring-mvc-java/src/main/java/org/baeldung/controller/UserController.java renamed to spring-mvc-java/src/main/java/org/baeldung/web/controller/UserController.java

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
package org.baeldung.controller;
2-
3-
import org.baeldung.model.UserDetails;
4-
import org.springframework.stereotype.Controller;
5-
import org.springframework.ui.Model;
6-
import org.springframework.web.bind.annotation.ModelAttribute;
7-
import org.springframework.web.bind.annotation.RequestMapping;
8-
import org.springframework.web.bind.annotation.RequestMethod;
9-
10-
@Controller
11-
@RequestMapping("/")
12-
public class UserController {
13-
14-
@RequestMapping(value = "/", method = RequestMethod.GET)
15-
public String showForm(final Model model) {
16-
final UserDetails user = new UserDetails();
17-
user.setFirstname("John");
18-
user.setLastname("Roy");
19-
user.setEmailId("[email protected]");
20-
model.addAttribute("user", user);
21-
return "index";
22-
}
23-
24-
@RequestMapping(value = "/processForm", method = RequestMethod.POST)
25-
public String processForm(@ModelAttribute(value = "user") final UserDetails user, final Model model) {
26-
// Insert userDetails into DB
27-
model.addAttribute("name", user.getFirstname() + " " + user.getLastname());
28-
return "hello";
29-
}
30-
31-
}
1+
package org.baeldung.web.controller;
2+
3+
import org.baeldung.model.User;
4+
import org.springframework.stereotype.Controller;
5+
import org.springframework.ui.Model;
6+
import org.springframework.web.bind.annotation.ModelAttribute;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
import org.springframework.web.bind.annotation.RequestMethod;
9+
10+
@Controller
11+
@RequestMapping("/")
12+
public class UserController {
13+
14+
@RequestMapping(value = "/", method = RequestMethod.GET)
15+
public String showForm(final Model model) {
16+
final User user = new User();
17+
user.setFirstname("John");
18+
user.setLastname("Roy");
19+
user.setEmailId("[email protected]");
20+
model.addAttribute("user", user);
21+
return "index";
22+
}
23+
24+
@RequestMapping(value = "/processForm", method = RequestMethod.POST)
25+
public String processForm(@ModelAttribute(value = "user") final User user,
26+
final Model model) {
27+
// Insert User into DB
28+
model.addAttribute("name", user.getFirstname() + " " + user.getLastname());
29+
return "hello";
30+
}
31+
32+
}

0 commit comments

Comments
 (0)