diff --git a/.classpath b/.classpath index 9ba41a2..54078e2 100644 --- a/.classpath +++ b/.classpath @@ -1,34 +1,39 @@ - + - - + + + + + + - + + - + + - + - + - - + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index e9441bb..abdea9a 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ eclipse.preferences.version=1 encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 46235dc..7797211 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.methodParameters=generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled diff --git a/pom.xml b/pom.xml index a31ce19..6859331 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,12 @@ 4.0.0 - + + org.springframework.boot + spring-boot-starter-parent + 2.4.0-M3 + + MTGClone MTGClone 1.0 @@ -18,6 +23,25 @@ + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.tomcat.embed + tomcat-embed-jasper + provided + junit junit @@ -34,11 +58,16 @@ + + org.springframework.boot + spring-boot-maven-plugin + maven-clean-plugin 3.1.0 + maven-resources-plugin @@ -105,4 +134,19 @@ + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + diff --git a/src/main/java/MTGClone/MTGSpringApp.java b/src/main/java/MTGClone/MTGSpringApp.java new file mode 100644 index 0000000..36b8408 --- /dev/null +++ b/src/main/java/MTGClone/MTGSpringApp.java @@ -0,0 +1,20 @@ +package MTGClone; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +@SpringBootApplication +public class MTGSpringApp extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(MTGSpringApp.class); + } + + public static void main(String[] args) { + SpringApplication.run(MTGSpringApp.class, args); + } + +} diff --git a/src/main/java/MTGClone/controller/HelloController.java b/src/main/java/MTGClone/controller/HelloController.java new file mode 100644 index 0000000..d82997a --- /dev/null +++ b/src/main/java/MTGClone/controller/HelloController.java @@ -0,0 +1,23 @@ +package MTGClone.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@Controller +public class HelloController { + @GetMapping({"/", "/hello"}) + public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) { + model.addAttribute("name", name); + return "hello"; + } + + @PostMapping({"/greet"}) + public String greet(@RequestParam("name") String name, ModelMap modelMap) { + modelMap.put("name", name); + return "hello"; + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..94e7fcc --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,2 @@ +spring.mvc.view.prefix=/WEB-INF/jsp/ +spring.mvc.view.suffix=.jsp diff --git a/src/main/webapp/WEB-INF/jsp/hello.jsp b/src/main/webapp/WEB-INF/jsp/hello.jsp new file mode 100644 index 0000000..1fbb642 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/hello.jsp @@ -0,0 +1,16 @@ + + + + + + Hello ${name}! + + +

Hello ${name}!

+
+ +

+ +
+ + \ No newline at end of file