-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.example; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
import java.util.Map; | ||
|
||
@Controller | ||
public class GreetingsController { | ||
@Autowired | ||
private InfoRepository infoRepository; | ||
@GetMapping("/") | ||
public String greeting(Map<String, Object> model) { | ||
|
||
return "greeting"; | ||
} | ||
@GetMapping("/main") | ||
public String main(Map<String, Object> model) { | ||
Iterable<Info> info = infoRepository.findAll(); | ||
model.put("info", info); | ||
return "main"; | ||
} | ||
|
||
@PostMapping("/main") | ||
public String add(@RequestParam String name, @RequestParam String email, Map<String, Object> model) | ||
{ | ||
Info info = new Info(name, email); | ||
|
||
infoRepository.save(info); | ||
|
||
infoRepository.findAll(); | ||
model.put("info", info); | ||
return "main"; | ||
} | ||
|
||
} |