2021-08-08
This commit is contained in:
20
mvc/src/main/java/kr/pe/elex/examples/Application.java
Normal file
20
mvc/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);
|
||||
}
|
||||
|
||||
}
|
||||
47
mvc/src/main/java/kr/pe/elex/examples/MyController.java
Normal file
47
mvc/src/main/java/kr/pe/elex/examples/MyController.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Spring-boot Examples
|
||||
*
|
||||
* Copyright (c) 2021. Elex. All Rights Reserved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping({"/my"})
|
||||
public class MyController {
|
||||
@Autowired
|
||||
private MyService service;
|
||||
|
||||
@GetMapping({"/"})
|
||||
public String index() {
|
||||
return "main";
|
||||
}
|
||||
|
||||
@GetMapping({"/path/{id}"})
|
||||
public String withPathVar(@PathVariable String id) {
|
||||
return "main";
|
||||
}
|
||||
|
||||
@GetMapping({"/request"})
|
||||
public String withReqVar(@RequestParam String id) {
|
||||
return "main";
|
||||
}
|
||||
|
||||
@PostMapping({"/post"})
|
||||
public String withPostBody(@RequestBody Person person) {
|
||||
return "main";
|
||||
}
|
||||
|
||||
@GetMapping({"/request/header"})
|
||||
public String withReqHeader(@RequestHeader MultiValueMap<String, String> headers) {
|
||||
return "main";
|
||||
}
|
||||
}
|
||||
14
mvc/src/main/java/kr/pe/elex/examples/MyService.java
Normal file
14
mvc/src/main/java/kr/pe/elex/examples/MyService.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package kr.pe.elex.examples;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MyService {
|
||||
public String doSomething(String param) throws IllegalArgumentException, Exception {
|
||||
if ("illegal" == param) throw new IllegalArgumentException("Oops~");
|
||||
if ("exception" == param) throw new Exception("Oops~");
|
||||
return "Hello";
|
||||
}
|
||||
}
|
||||
12
mvc/src/main/java/kr/pe/elex/examples/Person.java
Normal file
12
mvc/src/main/java/kr/pe/elex/examples/Person.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package kr.pe.elex.examples;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Person {
|
||||
@JsonProperty
|
||||
private String name;
|
||||
@JsonProperty
|
||||
private int age;
|
||||
}
|
||||
8
mvc/src/main/java/kr/pe/elex/examples/package-info.java
Normal file
8
mvc/src/main/java/kr/pe/elex/examples/package-info.java
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Spring-boot Examples
|
||||
*
|
||||
* Copyright (c) 2021. Elex. All Rights Reserved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples;
|
||||
9
mvc/src/main/resources/application.yaml
Normal file
9
mvc/src/main/resources/application.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
spring:
|
||||
application:
|
||||
name: My spring-boot project
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 128KB
|
||||
max-request-size: 128KB
|
||||
server:
|
||||
port: 8080
|
||||
10
mvc/src/main/resources/banner.txt
Normal file
10
mvc/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
('-. ('-. ) (`-.
|
||||
_( OO) _( OO) ( OO ).
|
||||
(,------.,--. (,------.(_/. \_)-.
|
||||
| .---'| |.-') | .---' \ `.' /
|
||||
| | | | OO ) | | \ /\
|
||||
(| '--. | |`-' |(| '--. \ \ |
|
||||
| .--'(| '---.' | .--' .' \_)
|
||||
| `---.| | | `---. / .'. \
|
||||
`------'`------' `------''--' '--'
|
||||
powered by ELEX
|
||||
48
mvc/src/main/resources/logback-spring.xml
Normal file
48
mvc/src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Spring-boot Examples
|
||||
~
|
||||
~ Copyright (c) 2021. Elex. All Rights Reserved.
|
||||
~ https://www.elex-project.com/
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||
|
||||
<springProperty name="LOG_DIR" source="logging.path"
|
||||
defaultValue="${user.home}/logs"/>
|
||||
<property name="LOG_PATH" value="${LOG_DIR}/stephanie.log"/>
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="ROLLING-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<charset>UTF-8</charset>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
<file>${LOG_PATH}</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_DIR}/sebastian_%d{yyyy-MM-dd}_%i.log.gz</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<logger name="kr.pe.elex" level="debug" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="ROLLING-FILE"/>
|
||||
</logger>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="ROLLING-FILE"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
15
mvc/src/main/resources/templates/main.mustache
Normal file
15
mvc/src/main/resources/templates/main.mustache
Normal file
@@ -0,0 +1,15 @@
|
||||
<h1>File Upload Example!!!</h1>
|
||||
<form action="/upload" method="POST" enctype="multipart/form-data">
|
||||
<label for="file">Select a file: </label>
|
||||
<input id="file" name="file" type="file" title="Upload"/>
|
||||
<div>
|
||||
<button>Upload</button>
|
||||
</div>
|
||||
</form>
|
||||
<h2>Uploaded Files</h2>
|
||||
<p>Click to download.</p>
|
||||
<ul>
|
||||
{{#files}}
|
||||
<li><a href="/files/{{.}}">{{.}}</a></li>
|
||||
{{/files}}
|
||||
</ul>
|
||||
Reference in New Issue
Block a user