프론트 컨트롤러 기본프레임
package com.codingbox.board;
import java.io.IOException;
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;
@WebServlet
public class BoardFrontController extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
private void doProcess(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String requestURI = request.getRequestURI();
ActionForward forward = null;
if( forward != null ) {
if( forward.isRedirect() ) {
// true : redirect
response.sendRedirect(forward.getPath());
} else {
// false : forward
RequestDispatcher disp = request.getRequestDispatcher(forward.getPath());
disp.forward(request, response);
}
}
}
DAO 기본 프레임
public class BoardDAO {
SqlSessionFactory factory = SqlMapConfig.getFactory();
SqlSession sqlsession;
public BoardDAO() {
sqlsession = factory.openSession(true);
}
}