일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- setAttribute
- NOTE
- jsp
- Framework
- backend
- Agile
- DevOps
- handlerMapping
- 프롬프트
- Spring
- 맥린이
- getParameter
- UML
- getAttribute
- HTTP
- mybatis
- usecasediagram
- App
- Cloud
- classdiagram
- 내장객체
- tiles
- Program
- system developer
- ERD
- MVC
- command
- FrontController
- controller
- pattern
Archives
- Today
- Total
시작은 언제라도
FrontController Pattern - 1 본문
findcar-form.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>차정보 조회-form</title>
</head>
<body>
<%--
jsp -- FrontControllerServlet --Model
|
findcar-ok.jsp
findcar-fail.jsp
--%>
<form action="FrontControllerServlet">
<input type="hidden" name="command" value="FindCar">
차번호 <input type="number" required="required" name="carNo">
<input type="submit" value="검색">
</form>
</body>
</html>
차정보 조회 form.jsp에서 FrontControllerServlet으로 차번호(CarNo)와 hidden command(FindCar)을 보낸다.
FrontControllerServlet.java
package org.kosta.webstudy17.controller;
import java.io.IOException;
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 org.kosta.webstudy17.model.MockDAO;
@WebServlet("/FrontControllerServlet")
public class FrontControllerServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public FrontControllerServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
handleRequest(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
handleRequest(request,response);
}
FrontControllerServlet의 나머지 코드는 뒤의 예제들에서 찾아보자
'Web programming > Patterns' 카테고리의 다른 글
Command Design Pattern (0) | 2021.04.18 |
---|---|
3. FrontControllerServlet ex3 (0) | 2021.04.18 |
2. FrontControllerServlet ex2 (0) | 2021.04.18 |
1. FrontControllerServlet ex1 (0) | 2021.04.18 |
Design Pattern 이란? (0) | 2021.04.18 |