diff --git a/hospital/src/main/java/command/Command.java b/hospital/src/main/java/command/Command.java new file mode 100644 index 0000000..b173b6c --- /dev/null +++ b/hospital/src/main/java/command/Command.java @@ -0,0 +1,11 @@ +package command; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public interface Command { + public String exec(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException; +} diff --git a/hospital/src/main/java/command/HomeCommand.java b/hospital/src/main/java/command/HomeCommand.java new file mode 100644 index 0000000..4952f17 --- /dev/null +++ b/hospital/src/main/java/command/HomeCommand.java @@ -0,0 +1,14 @@ +package command; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class HomeCommand implements Command { + public String exec(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ + + return "home.jsp"; + } +} diff --git a/hospital/src/main/java/command/LoginCommand.java b/hospital/src/main/java/command/LoginCommand.java new file mode 100644 index 0000000..064bd77 --- /dev/null +++ b/hospital/src/main/java/command/LoginCommand.java @@ -0,0 +1,17 @@ +package command; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class LoginCommand implements Command { + @Override + public String exec(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ + //TODO : DB작업 필요 + + + return "views/student/loginForm.jsp"; + } +} diff --git a/hospital/src/main/java/controller/Fcontroller.java b/hospital/src/main/java/controller/Fcontroller.java new file mode 100644 index 0000000..3e368b8 --- /dev/null +++ b/hospital/src/main/java/controller/Fcontroller.java @@ -0,0 +1,52 @@ +package controller; + +import java.io.IOException; +import java.util.HashMap; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletConfig; +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 command.Command; +import command.HomeCommand; +import command.LoginCommand; + +@WebServlet("/Fcontroller") +public class Fcontroller extends HttpServlet { + private static final long serialVersionUID = 1L; + HashMap list = null; + public Fcontroller() { + super(); + // TODO Auto-generated constructor stub + } + + public void init(ServletConfig config) throws ServletException { + // TODO Auto-generated method stub + list = new HashMap(); + + list.put("/login.do", new LoginCommand()); //로그인 처리 + list.put("/home.do", new HomeCommand()); //처음 보여주는 페이지; + //이 부분에 계속적으로 매핑을 추가하면 됨 + + } + + protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + request.setCharacterEncoding("utf-8"); + String uri = request.getRequestURI(); + + String contextPath = request.getContextPath(); + String path = uri.substring(contextPath.length()); + Command comm = list.get(path); + String view = comm.exec(request, response); + + RequestDispatcher dispatcher = request.getRequestDispatcher(view); + dispatcher.forward(request, response); + } + +} + \ No newline at end of file diff --git a/hospital/src/main/webapp/WEB-INF/web.xml b/hospital/src/main/webapp/WEB-INF/web.xml index 70070ff..7512a42 100644 --- a/hospital/src/main/webapp/WEB-INF/web.xml +++ b/hospital/src/main/webapp/WEB-INF/web.xml @@ -8,6 +8,14 @@ version="3.1"> Archetype Created Web Application + + FrontController + controller.Fcontroller + + + FrontController + *.do + index.jsp diff --git a/hospital/src/main/webapp/home.jsp b/hospital/src/main/webapp/home.jsp new file mode 100644 index 0000000..880bb5b --- /dev/null +++ b/hospital/src/main/webapp/home.jsp @@ -0,0 +1,21 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Insert title here + + +

what the hell?

+ + +

병원 임직원 회원가입

+ +아이디 :
+암호 :
+이름 :
+e-mail :

+ + + \ No newline at end of file diff --git a/hospital/src/main/webapp/index.jsp b/hospital/src/main/webapp/index.jsp index 24d9017..59f6e7b 100644 --- a/hospital/src/main/webapp/index.jsp +++ b/hospital/src/main/webapp/index.jsp @@ -5,16 +5,8 @@ 병원 관리 시스템 + - -

병원 임직원 회원가입

-
- -아이디 :
-암호 :
-이름 :
-e-mail :

-

- \ No newline at end of file + \ No newline at end of file