Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c4a6309
feat: create CreateUserController
hyungyu-02 Oct 10, 2025
3192ad9
feat: create ListUserController
hyungyu-02 Oct 10, 2025
8d290b7
feat: create LoginController
hyungyu-02 Oct 10, 2025
4722d2f
feat: create LogoutController
hyungyu-02 Oct 10, 2025
87b80d5
feat: create UpdateUserFormController
hyungyu-02 Oct 10, 2025
aa2d814
feat: create UpdateUserController
hyungyu-02 Oct 10, 2025
18dc9fa
fix: fix mistakes
hyungyu-02 Oct 10, 2025
995088a
fix: 회원 목록 및 개인정보 수정 보안 강화
hyungyu-02 Oct 10, 2025
0e01e54
feat: create Controller, RequestMapper, DispatcherServlet
hyungyu-02 Oct 10, 2025
177e606
refactor: change controllers for use Controller interface and create …
hyungyu-02 Oct 10, 2025
8ffbfc4
refactor: use static
hyungyu-02 Oct 10, 2025
1e570b7
feat: create UserDao
hyungyu-02 Nov 2, 2025
c826a27
feat: activate contextInitialized function
hyungyu-02 Nov 2, 2025
b6a55ba
feat: create JdbcTemplate.java and PreparedStatementSetter.java
hyungyu-02 Nov 2, 2025
18b3b83
feat: use JdbcTemplate and PreparedStatementSetter in UserDao.java
hyungyu-02 Nov 2, 2025
751c393
feat: add query and queryForObject function
hyungyu-02 Nov 2, 2025
207e1b4
feat: create RowMapper.java
hyungyu-02 Nov 2, 2025
0e87fba
feat: use query and queryForObject in UserDao.java
hyungyu-02 Nov 2, 2025
2007a03
refactor: use try's automatic resource management
hyungyu-02 Nov 2, 2025
caf5767
refactor: change JdbcTemplate to use generic type
hyungyu-02 Nov 2, 2025
b51a686
feat: Implement Q&A feature (Missions 0-3)
hyungyu-02 Nov 2, 2025
85d0185
build: gradle and properties setting
hyungyu-02 Nov 6, 2025
8df3ba1
6주차 강의영상까지 따라함
hyungyu-02 Nov 6, 2025
e280f84
refactor: migration LoginController.java to UserController.java
hyungyu-02 Nov 6, 2025
c8c2e7a
refactor(model): Question 모델을 JPA Entity로 변경
hyungyu-02 Nov 7, 2025
0ff8168
refactor(HomeController): HomeController 변경
hyungyu-02 Nov 7, 2025
3e63622
refactor(QuestionDao): QuestionDao 변경
hyungyu-02 Nov 7, 2025
b4a8c61
refactor(UserController): ForwardControllers 변경
hyungyu-02 Nov 7, 2025
9359759
refactor(UserController): LogoutController 변경
hyungyu-02 Nov 7, 2025
2d040b1
refactor(UserController): UpdateUserFormController 변경
hyungyu-02 Nov 7, 2025
c02795e
refactor(UserController): UpdateUserController 변경
hyungyu-02 Nov 7, 2025
46e6670
refactor(QnaController): CreateQuestionController and CreateQuestionF…
hyungyu-02 Nov 7, 2025
689b6bd
refactor(QnaController): ShowQuestionController 변경
hyungyu-02 Nov 7, 2025
820c311
refactor: 사용하지 않는 낡은 프레임워크 코드 삭제
hyungyu-02 Nov 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,46 +1,38 @@
plugins {
id 'org.springframework.boot' version '2.7.17'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
id 'idea'
}

idea {
module {
inheritOutputDirs = false
outputDir = file('./webapp/WEB-INF/classes')
}
}

group 'org.example'
version '1.0-SNAPSHOT'
group = 'org.example'
version = '1.0-SNAPSHOT'
sourceCompatibility = '17' // 현재 프로젝트 SDK 17에 맞춤

repositories {
mavenCentral()
}

ext {
springVersion = "5.1.8.RELEASE"
tomcatVersion = '8.5.42'
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testImplementation "org.springframework:spring-test:$springVersion"
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
// Web
implementation 'org.springframework.boot:spring-boot-starter-web'

// JPA
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

implementation("org.springframework:spring-jdbc:$springVersion")
implementation("org.springframework:spring-web:$springVersion")
implementation "org.reflections:reflections:0.10.2"
// JSP
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
implementation 'javax.servlet:jstl:1.2'

implementation("org.apache.commons:commons-dbcp2:2.6.0")
// DB Drivers (둘 다 두되 실제 사용 DB는 properties로 선택)
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'

runtimeOnly("com.h2database:h2:2.1.214")
runtimeOnly('mysql:mysql-connector-java:8.0.28')
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

implementation("org.apache.tomcat.embed:tomcat-embed-core:$tomcatVersion")
implementation("org.apache.tomcat.embed:tomcat-embed-logging-juli:8.5.2")
implementation("org.apache.tomcat.embed:tomcat-embed-jasper:$tomcatVersion")
implementation group: 'javax.servlet', name: 'jstl', version: '1.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.7.1'
// Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

test {
Expand Down
850 changes: 806 additions & 44 deletions java-webMVC.ipr

Large diffs are not rendered by default.

817 changes: 656 additions & 161 deletions java-webMVC.iws

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions src/main/java/WebServerLauncher.java

This file was deleted.

41 changes: 0 additions & 41 deletions src/main/java/core/db/MemoryUserRepository.java

This file was deleted.

11 changes: 0 additions & 11 deletions src/main/java/core/db/Repository.java

This file was deleted.

34 changes: 0 additions & 34 deletions src/main/java/core/jdbc/ConnectionManager.java

This file was deleted.

28 changes: 0 additions & 28 deletions src/main/java/core/web/filter/CharacterEncodingFilter.java

This file was deleted.

58 changes: 0 additions & 58 deletions src/main/java/core/web/filter/ResourceFilter.java

This file was deleted.

11 changes: 11 additions & 0 deletions src/main/java/jwp/WebServerLauncher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package jwp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class WebServerLauncher {
public static void main(String[] args) throws Exception {
SpringApplication.run(WebServerLauncher.class, args);
}
}
32 changes: 19 additions & 13 deletions src/main/java/jwp/controller/HomeController.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package jwp.controller;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import jwp.dao.QuestionDao;
import jwp.model.Question;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@WebServlet("/")
public class HomeController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
RequestDispatcher rd = req.getRequestDispatcher("/home.jsp");
rd.forward(req, resp);
import java.sql.SQLException;
import java.util.List;

@Controller
@RequiredArgsConstructor
public class HomeController {
private final QuestionDao questionDao;

@GetMapping("/")
public String showHome(Model model) throws SQLException {
List<Question> questions = questionDao.findAll();
model.addAttribute("questions", questions);
return "home";
}
}
66 changes: 66 additions & 0 deletions src/main/java/jwp/controller/QnaController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package jwp.controller;

import jwp.dao.QuestionDao;
import jwp.model.Question;
import jwp.model.User;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.sql.SQLException;

@Controller
@RequestMapping("/qna")
@RequiredArgsConstructor
public class QnaController {
private final QuestionDao questionDao;

@GetMapping("/form")
public String showQuestionForm(HttpSession session) {
if (!UserSessionUtils.isLogined(session)) {
return "redirect:/user/loginForm";
}
return "qna/form";
// 화살촉 안티패턴을 피하고 Guard Clause 사용을 위해 비로그인 처리 로직을 위의 if문에
}

@PostMapping("/create")
public String createQuestion(
@RequestParam("title") String title,
@RequestParam("contents") String contents,
HttpSession session
) {
User sessionUser = (User) session.getAttribute("user");
if (sessionUser == null) {
return "redirect:/user/loginForm";
}

Question questionToSave = new Question(
sessionUser.getUserId(),
title,
contents
);

questionDao.insert(questionToSave);

return "redirect:/qna/show?questionId=" + questionToSave.getQuestionId();
}

@GetMapping("/show")
public String showQuestion(@RequestParam("questionId") String questionIdParam, Model model) throws SQLException {
long questionId = Long.parseLong(questionIdParam);

Question question = questionDao.findByQuestionId(questionId);

if (question == null) {
System.out.println("해당 ID의 질문을 찾을 수 없습니다: " + questionId);
return "redirect:/";
}

model.addAttribute("question", question);

return "qna/show";
}
}
Loading