2021-08-02
This commit is contained in:
20
testing/src/main/java/kr/pe/elex/examples/Application.java
Normal file
20
testing/src/main/java/kr/pe/elex/examples/Application.java
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Spring-boot Examples
|
||||
*
|
||||
* Copyright (c) 2021. Elex. All Rights Reserved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
41
testing/src/main/java/kr/pe/elex/examples/MyController.java
Normal file
41
testing/src/main/java/kr/pe/elex/examples/MyController.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Spring-boot Examples
|
||||
*
|
||||
* Copyright (c) 2021. Elex. All Rights Reserved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples;
|
||||
|
||||
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.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
public class MyController {
|
||||
|
||||
@Autowired
|
||||
private MyService service;
|
||||
|
||||
@GetMapping({"/"})
|
||||
public String index(Model model) {
|
||||
model.addAttribute("name", "World");
|
||||
return "main";
|
||||
}
|
||||
|
||||
@GetMapping({"/{name}"})
|
||||
public String index(@PathVariable @ModelAttribute String name) {
|
||||
if (null == name) name = "World";
|
||||
return "main";
|
||||
}
|
||||
|
||||
@GetMapping("/greetings")
|
||||
@ResponseBody
|
||||
public String greetings() {
|
||||
return service.sayHello();
|
||||
}
|
||||
}
|
||||
17
testing/src/main/java/kr/pe/elex/examples/MyService.java
Normal file
17
testing/src/main/java/kr/pe/elex/examples/MyService.java
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Spring-boot Examples
|
||||
*
|
||||
* Copyright (c) 2021. Elex. All Rights Reserved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MyService {
|
||||
public String sayHello() {
|
||||
return "Hello, World.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Spring-boot Examples
|
||||
*
|
||||
* Copyright (c) 2021. Elex. All Rights Reserved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples;
|
||||
2
testing/src/main/resources/templates/main.mustache
Normal file
2
testing/src/main/resources/templates/main.mustache
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>HOME</h1>
|
||||
<p>Hello, {{name}}!</p>
|
||||
Reference in New Issue
Block a user