From ed766c8d177faf642f29f2cd72efade9af298eff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=9A=A9?= <1dlwnsdyd1@gmail.com>
Date: Sun, 2 Nov 2025 23:07:36 +0900
Subject: [PATCH 08/16] =?UTF-8?q?Fix:=20Utils=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/jwp/controller/LoginController.java | 8 +-------
src/main/java/jwp/controller/LogoutController.java | 6 ++++--
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/main/java/jwp/controller/LoginController.java b/src/main/java/jwp/controller/LoginController.java
index 3fb5d41..311a32a 100644
--- a/src/main/java/jwp/controller/LoginController.java
+++ b/src/main/java/jwp/controller/LoginController.java
@@ -1,13 +1,7 @@
package jwp.controller;
-
-//import core.db.MemoryUserRepository;
import jwp.dao.UserDao;
import jwp.model.User;
-
-import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpServlet;
import jwp.support.session.UserSessionUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -16,7 +10,7 @@
import java.sql.SQLException;
public class LoginController implements Controller {
- private static final String USER_SESSION_KEY = "user";
+// private static final String USER_SESSION_KEY = "user";
// private static final MemoryUserRepository userRepository = MemoryUserRepository.getInstance();
private final UserDao userDao = new UserDao();
@Override
diff --git a/src/main/java/jwp/controller/LogoutController.java b/src/main/java/jwp/controller/LogoutController.java
index c00efa1..a95cbf5 100644
--- a/src/main/java/jwp/controller/LogoutController.java
+++ b/src/main/java/jwp/controller/LogoutController.java
@@ -1,5 +1,7 @@
package jwp.controller;
+import jwp.support.session.UserSessionUtils;
+
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
@@ -9,13 +11,13 @@
import java.io.IOException;
public class LogoutController implements Controller {
- private static final String USER_SESSION_KEY = "user";
+// private static final String USER_SESSION_KEY = "user";
@Override
public String execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
HttpSession session = req.getSession(false);
if (session != null) {
- session.removeAttribute(USER_SESSION_KEY);
+ session.removeAttribute(UserSessionUtils.USER_SESSION_KEY);
}
return "redirect:/";
}
From aa19e299c1fa1f17a5f2f6474e4cfc44e3787f96 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=9A=A9?= <1dlwnsdyd1@gmail.com>
Date: Sun, 2 Nov 2025 23:41:44 +0900
Subject: [PATCH 09/16] Fix
---
java-webMVC.iws | 7 +--
.../java/jwp/controller/RequestMapping.java | 2 +
.../controller/ShowQuestionController.java | 39 ++++++++++++++++
webapp/include/navigation.jspf | 6 ++-
webapp/qna/form.jsp | 46 +++++++++----------
5 files changed, 72 insertions(+), 28 deletions(-)
create mode 100644 src/main/java/jwp/controller/ShowQuestionController.java
diff --git a/java-webMVC.iws b/java-webMVC.iws
index a5e8411..bdcb329 100644
--- a/java-webMVC.iws
+++ b/java-webMVC.iws
@@ -5,10 +5,11 @@
+
-
-
+
+
@@ -291,7 +292,7 @@
-
+
diff --git a/src/main/java/jwp/controller/RequestMapping.java b/src/main/java/jwp/controller/RequestMapping.java
index 7ca5230..0e9a448 100644
--- a/src/main/java/jwp/controller/RequestMapping.java
+++ b/src/main/java/jwp/controller/RequestMapping.java
@@ -18,8 +18,10 @@ public void init() {
mappings.put("/user/loginFailed", new ForwardController("/user/loginFailed.jsp"));
mappings.put("/qna/form", new CreateQuestionFormController());
mappings.put("/qna/create", new CreateQuestionController());
+ mappings.put("/qna/show", new ShowQuestionController());
}
+
public Controller getController(String path) {
return mappings.get(path);
}
diff --git a/src/main/java/jwp/controller/ShowQuestionController.java b/src/main/java/jwp/controller/ShowQuestionController.java
new file mode 100644
index 0000000..4083a48
--- /dev/null
+++ b/src/main/java/jwp/controller/ShowQuestionController.java
@@ -0,0 +1,39 @@
+package jwp.controller;
+
+import jwp.dao.QuestionDao;
+import jwp.model.Question;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.sql.SQLException;
+
+public class ShowQuestionController implements Controller {
+ private final QuestionDao questionDao = new QuestionDao();
+
+ @Override
+ public String execute(HttpServletRequest req, HttpServletResponse resp) throws IOException, SQLException {
+ String questionIdParam = req.getParameter("questionId");
+ if (questionIdParam == null || questionIdParam.isBlank()) {
+ resp.sendRedirect("/");
+ return null;
+ }
+
+ long questionId;
+ try {
+ questionId = Long.parseLong(questionIdParam);
+ } catch (NumberFormatException e) {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
+ return null;
+ }
+
+ Question question = questionDao.findByQuestionId(questionId);
+ if (question == null) {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ return null;
+ }
+
+ req.setAttribute("question", question);
+ return "/qna/show.jsp";
+ }
+}
diff --git a/webapp/include/navigation.jspf b/webapp/include/navigation.jspf
index ed221f9..162999f 100644
--- a/webapp/include/navigation.jspf
+++ b/webapp/include/navigation.jspf
@@ -30,8 +30,10 @@
diff --git a/webapp/qna/form.jsp b/webapp/qna/form.jsp
index 5d62cb5..2677faf 100644
--- a/webapp/qna/form.jsp
+++ b/webapp/qna/form.jsp
@@ -9,30 +9,30 @@
-<%--
--%>
+ <%-- --%>
-<%-- --%>
-<%-- --%>
+ <%-- --%>
+ <%-- --%>
From 699f385654c73ab988c22c4bfcf258cdf97b785a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=9A=A9?= <1dlwnsdyd1@gmail.com>
Date: Mon, 3 Nov 2025 00:17:58 +0900
Subject: [PATCH 11/16] Add: Show.jsp Done
---
java-webMVC.iws | 5 +-
webapp/qna/show.jsp | 252 ++++++++++++++++++++++++++------------------
2 files changed, 153 insertions(+), 104 deletions(-)
diff --git a/java-webMVC.iws b/java-webMVC.iws
index 1ad94c6..9f08171 100644
--- a/java-webMVC.iws
+++ b/java-webMVC.iws
@@ -5,8 +5,7 @@
-
-
+
@@ -289,7 +288,7 @@
-
+
diff --git a/webapp/qna/show.jsp b/webapp/qna/show.jsp
index 7e89769..83bc994 100644
--- a/webapp/qna/show.jsp
+++ b/webapp/qna/show.jsp
@@ -1,114 +1,162 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
-<%@ include file="/include/header.jspf"%>
+<%@ include file="/include/header.jspf" %>
<%@ include file="/include/navigation.jspf" %>
-
-
-
-
-
-
-

-
-
-
-
이영선
-
- 2024-09-29 22:11
+
+
+
+
+
+
+

+
+
+
+ <%-- 이영선--%>
+ ${question.writer}
+
+<%-- 2024-09-29 22:11--%>
+ ${question.createdDate}
-
-
-
-
저는 지금 '객체지향의 사실과 오해' 라는 책을 읽고 있는데 정말 좋아요
-
이해가 쏙쏙 됩니다!
-
-
-
- -
-
- 수정
-
- -
-
-
-
- -
- 목록
-
-
-
-
-
-
-
+
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
From dc2fd96b568b0b53ed8075ce8bd364042b89891e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=9A=A9?= <1dlwnsdyd1@gmail.com>
Date: Wed, 5 Nov 2025 18:49:18 +0900
Subject: [PATCH 12/16] =?UTF-8?q?6=EC=A3=BC=EC=B0=A8=20=EC=9A=94=EA=B5=AC?=
=?UTF-8?q?=EC=82=AC=ED=95=AD=200=EB=8B=A8=EA=B3=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
build.gradle | 55 +-
java-webMVC.ipr | 646 +++++++++++++++---
java-webMVC.iws | 77 ++-
src/main/java/WebServerLauncher.java | 22 +-
src/main/java/core/jdbc/JdbcTemplate.java | 146 ++--
.../java/jwp/controller/UserController.java | 62 ++
src/main/java/jwp/dao/UserDao.java | 104 +--
src/main/java/jwp/model/User.java | 10 +
src/main/resources/application.properties | 14 +
.../main/webapp}/WEB-INF/.gitignore | 0
{webapp => src/main/webapp}/css/styles.css | 0
{webapp => src/main/webapp}/css/styles2.css | 0
{webapp => src/main/webapp}/favicon.ico | Bin
{webapp => src/main/webapp}/home.jsp | 0
{webapp => src/main/webapp}/img/KUIT.png | Bin
{webapp => src/main/webapp}/img/picture.jpeg | Bin
.../main/webapp}/include/header.jspf | 0
.../main/webapp}/include/navigation.jspf | 0
{webapp => src/main/webapp}/js/scripts.js | 0
{webapp => src/main/webapp}/qna/form.jsp | 0
{webapp => src/main/webapp}/qna/show.jsp | 0
{webapp => src/main/webapp}/user/form.jsp | 0
{webapp => src/main/webapp}/user/list.jsp | 0
{webapp => src/main/webapp}/user/login.jsp | 0
.../main/webapp}/user/loginFailed.jsp | 0
.../main/webapp}/user/updateForm.jsp | 0
26 files changed, 861 insertions(+), 275 deletions(-)
create mode 100644 src/main/java/jwp/controller/UserController.java
create mode 100644 src/main/resources/application.properties
rename {webapp => src/main/webapp}/WEB-INF/.gitignore (100%)
rename {webapp => src/main/webapp}/css/styles.css (100%)
rename {webapp => src/main/webapp}/css/styles2.css (100%)
rename {webapp => src/main/webapp}/favicon.ico (100%)
rename {webapp => src/main/webapp}/home.jsp (100%)
rename {webapp => src/main/webapp}/img/KUIT.png (100%)
rename {webapp => src/main/webapp}/img/picture.jpeg (100%)
rename {webapp => src/main/webapp}/include/header.jspf (100%)
rename {webapp => src/main/webapp}/include/navigation.jspf (100%)
rename {webapp => src/main/webapp}/js/scripts.js (100%)
rename {webapp => src/main/webapp}/qna/form.jsp (100%)
rename {webapp => src/main/webapp}/qna/show.jsp (100%)
rename {webapp => src/main/webapp}/user/form.jsp (100%)
rename {webapp => src/main/webapp}/user/list.jsp (100%)
rename {webapp => src/main/webapp}/user/login.jsp (100%)
rename {webapp => src/main/webapp}/user/loginFailed.jsp (100%)
rename {webapp => src/main/webapp}/user/updateForm.jsp (100%)
diff --git a/build.gradle b/build.gradle
index 7133144..4856ddc 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,53 +1,40 @@
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 = '11' // 사용하는 자바 버전에 맞게 설정 (예: 11)
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'
+ // 1. Spring Boot Web Starter
+ implementation 'org.springframework.boot:spring-boot-starter-web'
- implementation("org.springframework:spring-jdbc:$springVersion")
- implementation("org.springframework:spring-web:$springVersion")
- implementation "org.reflections:reflections:0.10.2"
+ // 2. Spring Boot Data JPA Starter
+ implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
- implementation("org.apache.commons:commons-dbcp2:2.6.0")
+ // 3. JSP 템플릿 엔진 사용을 위한 의존성
+ implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
+ implementation 'javax.servlet:jstl:1.2'
- runtimeOnly("com.h2database:h2:2.1.214")
- runtimeOnly('mysql:mysql-connector-java:8.0.28')
+ // 4. 데이터베이스 드라이버 (H2, MySQL 등 필요한 것 사용)
+ runtimeOnly 'com.h2database:h2'
+ runtimeOnly 'mysql:mysql-connector-java'
- 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'
+ // 5. Lombok (선택 사항이지만 강력히 추천)
+ compileOnly 'org.projectlombok:lombok'
+ annotationProcessor 'org.projectlombok:lombok'
+
+ // 6. Spring Boot Test Starter
+ testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
-}
-
-java {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
}
\ No newline at end of file
diff --git a/java-webMVC.ipr b/java-webMVC.ipr
index 92602d0..250433f 100644
--- a/java-webMVC.ipr
+++ b/java-webMVC.ipr
@@ -11,10 +11,20 @@
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
@@ -32,6 +42,7 @@
+
2개의 의견
-오브젝트여
---
-
- 수정
-
- -
-
-
-
-
-저는 지금 '객체지향의 사실과 오해' 라는 책을 읽고 있는데 정말 좋아요
--%> + <%--이해가 쏙쏙 됩니다!
--%> +${question.contents}
++-
+
+ <%-- 수정--%>
+ 수정
+
+ -
+
+ <%--
+
+ -
+ 목록
+
+
+2개의 의견
--%> +${answerCount}개의 의견
+오브젝트여
--%> + <%----%> + <%--- --%>
+ <%-- --%>
+ <%-- 수정--%>
+ <%--
--%>
+ <%-- - --%>
+ <%-- --%>
+ <%-- --%>
+ <%--
--%>
+ <%--
--%> + <%--스프링 입문을 위한 자바 객체 지향의 원리와 이해 추천합니다.
--%> + <%--(근데 저도 아직 안 읽었어요..)
--%> + <%----%> + <%--- --%>
+ <%-- --%>
+ <%-- 수정--%>
+ <%--
--%>
+ <%-- - --%>
+ <%-- --%>
+ <%-- --%>
+ <%--
--%>
+ <%--
--%> + <%--스프링 입문을 위한 자바 객체 지향의 원리와 이해 추천합니다.
-(근데 저도 아직 안 읽었어요..)
+${answer.contents}