Skip to content

gh #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

gh #2

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,57 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.webjars/jquery -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version> 1.11.1</version>
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.7.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.webjars/jquery -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>1.11.1</version>
</dependency>

</dependencies>
<build>
<plugins>
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/com/hellokoding/springboot/HelloController.java

This file was deleted.

11 changes: 5 additions & 6 deletions src/main/java/com/hellokoding/springboot/WebApplication.java
Original file line number Diff line number Diff line change
@@ -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);

}
}

Original file line number Diff line number Diff line change
@@ -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";
}



}
Original file line number Diff line number Diff line change
@@ -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();

}
}
13 changes: 13 additions & 0 deletions src/main/java/com/hellokoding/springboot/viewModel/VModel.java
Original file line number Diff line number Diff line change
@@ -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;

}
15 changes: 13 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
spring.mvc.view.prefix: /
spring.mvc.view.suffix: .jsp
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
77 changes: 77 additions & 0 deletions src/main/webapp/Good.jsp
Original file line number Diff line number Diff line change
@@ -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" %>
<html>
<head>
<title>Good</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
function SendVModel()
{
const v = {"id":"1","name":"John"};
// var v ={
// "id":"01",
// "name":"ali"
// }
$.ajax({
url: '/hey/save2/'+v,
type: 'GET',
data: JSON.stringify(v),
contentType: 'application/json; charset=utf-8',
dataType: 'json'
});
}
function SendVModel1()
{
const v = {"id":"1","name":"John"};
// var v ={
// "id":"01",
// "name":"ali"
// }
$.ajax({
url: '/hey/save3/'+v,
type: 'POST',
data: JSON.stringify(v),
contentType: 'application/json; charset=utf-8',
dataType: 'json'
});
}
function SendVModel2()
{
const v = {"id":"1","name":"John"};
// var v ={
// "id":"01",
// "name":"ali"
// }
$.ajax({
url: '/hey/save4/',
type: 'POST',
data: JSON.stringify(v),
contentType: 'application/json; charset=utf-8',
dataType: 'json'
});
}
function getClean()
{
$('#mname').val('');
$('#mid').val('');
}
</script>
</head>
<body style="background-color: cadetblue">
<input type="text" placeholder="id" id="mid">
<br>
<input type="text" placeholder="name" id="mname">
<br>
<a href="#" onclick="SendVModel();">sendSave2</a>
<a href="#" onclick="SendVModel1();">sendSave3</a>
<a href="#" onclick="SendVModel2();">sendSave4</a>
<br>
<a href="#" onclick="getClean();">clean</a>
</body>
</html>
37 changes: 33 additions & 4 deletions src/main/webapp/hello.jsp
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello</title>
<title>home</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>
function getSave() {
console.log($('#nid').val());
if (confirm($('#nid').val()) == true) {
alert("true");
window.open("/hey/save/"+$('#nid').val())
} else
{
alert("false")
}
}
function good()
{
window.open("/home/Good");
}
function getClean()
{
$('#nid').val('');
}
</script>
</head>
<body>
Hello ${name}
<body style="background-color: antiquewhite;">

<input type="text" id="nid">
<br>
<a href="#" onclick="getSave();">send</a>
<br>
<a href="#" onclick="getClean();">clean</a>
<a href="#" onclick="good();">Next Page</a>
<button class="btn_save">okokok</button>

</body>
</html>
10 changes: 0 additions & 10 deletions src/main/webapp/index.html

This file was deleted.

23 changes: 23 additions & 0 deletions src/main/webapp/static/Style.css
Original file line number Diff line number Diff line change
@@ -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;
}
Binary file added src/main/webapp/static/pic/spiderman.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.