diff --git a/pom.xml b/pom.xml index 2d1904a..07868a2 100644 --- a/pom.xml +++ b/pom.xml @@ -20,18 +20,57 @@ org.springframework.boot spring-boot-starter-web - + + org.projectlombok + lombok + 1.18.20 + provided + + + net.sf.dozer + dozer + 5.5.1 + org.springframework.boot spring-boot-starter-tomcat provided + + + org.webjars + jquery + 1.11.1 + org.apache.tomcat.embed tomcat-embed-jasper provided + + + mysql + mysql-connector-java + 8.0.16 + + + + org.hibernate + hibernate-core + 5.3.7.Final + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.webjars + jquery + 1.11.1 + + diff --git a/src/main/java/com/hellokoding/springboot/HelloController.java b/src/main/java/com/hellokoding/springboot/HelloController.java deleted file mode 100644 index 4d264ea..0000000 --- a/src/main/java/com/hellokoding/springboot/HelloController.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hellokoding.springboot; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@Controller -public class HelloController { - @RequestMapping("/hello") - public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) { - model.addAttribute("name", name); - return "hello"; - } -} diff --git a/src/main/java/com/hellokoding/springboot/WebApplication.java b/src/main/java/com/hellokoding/springboot/WebApplication.java index 7567769..d311a81 100644 --- a/src/main/java/com/hellokoding/springboot/WebApplication.java +++ b/src/main/java/com/hellokoding/springboot/WebApplication.java @@ -1,19 +1,18 @@ package com.hellokoding.springboot; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.web.SpringBootServletInitializer; +import org.springframework.boot.orm.jpa.EntityScan; +import org.springframework.context.annotation.ComponentScan; @SpringBootApplication -public class WebApplication extends SpringBootServletInitializer { - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(WebApplication.class); - } - +public class WebApplication{ public static void main(String[] args) throws Exception { SpringApplication.run(WebApplication.class, args); + } } diff --git a/src/main/java/com/hellokoding/springboot/pageController/PageController.java b/src/main/java/com/hellokoding/springboot/pageController/PageController.java new file mode 100644 index 0000000..2915a3d --- /dev/null +++ b/src/main/java/com/hellokoding/springboot/pageController/PageController.java @@ -0,0 +1,26 @@ +package com.hellokoding.springboot.pageController; + + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Controller +@RequestMapping(value = "/home") +public class PageController { + + @RequestMapping(value = "/hello") + public String hello() + { + return "hello"; + } + + @RequestMapping(value = "/Good") + public String Good() + { + return "Good"; + } + + + +} diff --git a/src/main/java/com/hellokoding/springboot/pageController/RestController.java b/src/main/java/com/hellokoding/springboot/pageController/RestController.java new file mode 100644 index 0000000..7f45b4a --- /dev/null +++ b/src/main/java/com/hellokoding/springboot/pageController/RestController.java @@ -0,0 +1,50 @@ +package com.hellokoding.springboot.pageController; + + +import com.hellokoding.springboot.viewModel.VModel; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; + +@org.springframework.web.bind.annotation.RestController +@RequestMapping(value = "/hey") +public class RestController { + + @RequestMapping(value = "/save/{nid}",method = RequestMethod.GET) + public Long save(@PathVariable String nid) + { + System.out.println("hellllllo"+nid); + return 1l; + + } + @RequestMapping(value = "/save2/{v}",method = RequestMethod.GET) + @ResponseBody + public String save2(@RequestBody VModel v) + { + System.out.println("save2"); + System.out.println(v.getId()); + System.out.println(v.getName()); + return v.getName(); + + } + @RequestMapping(value = "/save3/{v}",method = RequestMethod.POST) + @ResponseBody + public String save3(@RequestBody VModel v) + { + System.out.println("save3"); + System.out.println(v.getId()); + System.out.println(v.getName()); + return v.getName(); + + } + @RequestMapping(value = "/save4",method = RequestMethod.POST) + @ResponseBody + public String save4(@RequestBody VModel v) + { + System.out.println("save4"); + System.out.println(v.getId()); + System.out.println(v.getName()); + return v.getName(); + + } +} diff --git a/src/main/java/com/hellokoding/springboot/viewModel/VModel.java b/src/main/java/com/hellokoding/springboot/viewModel/VModel.java new file mode 100644 index 0000000..0544538 --- /dev/null +++ b/src/main/java/com/hellokoding/springboot/viewModel/VModel.java @@ -0,0 +1,13 @@ +package com.hellokoding.springboot.viewModel; + + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class VModel { + private long id; + private String name; + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b416f5e..049606c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,13 @@ -spring.mvc.view.prefix: / -spring.mvc.view.suffix: .jsp \ No newline at end of file +server.port=8082 + +spring.mvc.view.prefix = / +spring.mvc.view.suffix = .jsp + + +spring.datasource.url = jdbc:mysql://localhost:3306/firstmydb +spring.datasource.username = root +spring.datasource.password = +spring.jpa.show-sql = true +spring.jpa.hibernate.ddl-auto = none +#spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect +#spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver diff --git a/src/main/webapp/Good.jsp b/src/main/webapp/Good.jsp new file mode 100644 index 0000000..fa4e638 --- /dev/null +++ b/src/main/webapp/Good.jsp @@ -0,0 +1,77 @@ +<%-- + Created by IntelliJ IDEA. + User: winph + Date: 8/6/2021 + Time: 11:23 AM + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Good + + + + + +
+ +
+sendSave2 +sendSave3 +sendSave4 +
+clean + + diff --git a/src/main/webapp/hello.jsp b/src/main/webapp/hello.jsp index 2791d2d..1d249f6 100644 --- a/src/main/webapp/hello.jsp +++ b/src/main/webapp/hello.jsp @@ -1,11 +1,40 @@ - - Hello + home + + + - - Hello ${name} + + + +
+send +
+clean +Next Page + + \ No newline at end of file diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html deleted file mode 100644 index e60b82a..0000000 --- a/src/main/webapp/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Spring Boot Hello World Example with JSP - - -

Spring Boot Hello World Example with JSP

- - \ No newline at end of file diff --git a/src/main/webapp/static/Style.css b/src/main/webapp/static/Style.css new file mode 100644 index 0000000..6e6aed4 --- /dev/null +++ b/src/main/webapp/static/Style.css @@ -0,0 +1,23 @@ +.btn_save +{ + + background-color: aliceblue; + color: black; +} +.btn_save:hover +{ + cursor: pointer; + background-color: green; + color: white; +} +.btn_clear +{ + background-color: aliceblue; + color: black; +} +.btn_clear:hover +{ + cursor: pointer; + background-color: dodgerblue; + color: white; +} \ No newline at end of file diff --git a/src/main/webapp/static/pic/spiderman.jpg b/src/main/webapp/static/pic/spiderman.jpg new file mode 100644 index 0000000..b5a3228 Binary files /dev/null and b/src/main/webapp/static/pic/spiderman.jpg differ