-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
upload/src/main/java/hello/upload/controller/ServletUploadControllerV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package hello.upload.controller; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.Part; | ||
import java.io.IOException; | ||
import java.util.Collection; | ||
|
||
@Slf4j | ||
@Controller | ||
@RequestMapping("/servlet/v1") | ||
public class ServletUploadControllerV1 { | ||
|
||
@GetMapping("/upload") | ||
public String newFile() { | ||
return "upload-form"; | ||
} | ||
|
||
@PostMapping("/upload") | ||
public String saveFileV1(HttpServletRequest request) throws ServletException, IOException { | ||
log.info("request={}", request); | ||
|
||
String itemName = request.getParameter("itemName"); | ||
log.info("itemName={}", itemName); | ||
|
||
Collection<Part> parts = request.getParts(); | ||
log.info("parts={}", parts); | ||
|
||
return "upload-form"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
|
||
logging.level.org.apache.coyote.http11=debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE HTML> | ||
<html xmlns:th="http://www.thymeleaf.org"> | ||
<head> | ||
<meta charset="utf-8"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="py-5 text-center"> | ||
<h2>상품 등록 폼</h2> | ||
</div> | ||
<h4 class="mb-3">상품 입력</h4> | ||
<form th:action method="post" enctype="multipart/form-data"> | ||
<ul> | ||
<li>상품명 <input type="text" name="itemName"></li> | ||
<li>파일<input type="file" name="file" ></li> | ||
</ul> | ||
<input type="submit"/> | ||
</form> | ||
</div> <!-- /container --> | ||
</body> | ||
</html> |