-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[톰캣 구현하기 1, 2단계] 마코(이규성) 미션 제출합니다. (#332)
* feat: 1단계 - HTTP 서버 구현하기 * feat: 2단계 - 1.HTTP Status Code 302 * feat: 2단계 - 2. POST 방식으로 회원가입 * feat: 2단계 - 3,4 Cookie에 JSESSIONID 값 저장하기 및 Session 구현하기 * refactor: 개행 정리 및 불필요한 메서드 제거 * refactor: 상수 대문자로 변경 * refactor: 뷰 리졸버 분리 리팩토링 * refactor: RequestBuilder 도입 * refactor: 사용하지 않는 import 제거 * refactor: 패키지 이동
- Loading branch information
Showing
25 changed files
with
1,031 additions
and
104 deletions.
There are no files selected for viewing
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
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
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,37 @@ | ||
package common; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
public class FileReader { | ||
|
||
private static final String STATIC_RESOURCE_PATH = "static"; | ||
private static final String EXTENSION_HTML = ".html"; | ||
|
||
private FileReader() { | ||
} | ||
|
||
public static String readFile(String uri) throws IOException { | ||
URL resource = findResource(uri); | ||
Path path = Paths.get(resource.getFile()); | ||
return new String(Files.readAllBytes(path)); | ||
} | ||
|
||
private static URL findResource(String fileName) { | ||
URL resource = FileReader.class.getClassLoader() | ||
.getResource(STATIC_RESOURCE_PATH + fileName); | ||
if (resource == null) { | ||
fileName = fileName + EXTENSION_HTML; | ||
resource = FileReader.class.getClassLoader() | ||
.getResource(STATIC_RESOURCE_PATH + fileName); | ||
} | ||
if (resource == null) { | ||
return FileReader.class.getClassLoader() | ||
.getResource(STATIC_RESOURCE_PATH + "/404.html"); | ||
} | ||
return resource; | ||
} | ||
} |
Oops, something went wrong.