java enterprise 프로젝트 생성(project template : web application, language : java, build system : gradle,
test framework : junit, specifications : servlet)
build.gradle 의존성 주입하기
ㄴlog4j2 maven : Apache Log4j Core(central 2.14.0),
Apache Log4j API(central 2.14.0)
ㄴjstl maven : central
ㄴlombok maven : gradle
※ lombok 의존성 주입시 annotationProcessor, testAnnotationProcessor 추가해야 함.
그리고 file->settings->build,execution,deployment
->compiler->annotation processors->enable annotation processing 체크.
WEB-INF 밑에 JSP 파일을 생성한다. (WEB-INF 밑에 있는 파일은 인터넷에서 직접 호출할 수 없음) (controller를 통해서 jsp파일을 호출하기 위함임)
ㄴcalcInput.jsp, calcResult.jsp
※ 그리고 webapp 밑에 index.jsp 삭제.
※ 메인 패키지 밑에 있는 HelloServlet 삭제.
web.xml 파일에 'welcome-file-list' 작성
ㄴwelcome-file-list에 있는 값과 controller의 value값이 일치 하는 doGet,doPost의 dispatcher의 파일로 이동함..
src->main->java->org->zerock->xxx->controller 밑에 '~Controller 서블릿 파일을 생성.
ㄴ'@Log4j2 어노테이션 추가.
ㄴdoGet 메서드와 doPost메서드에 각각 RequestDispatcher dispatcher=request.getRequestDispatcher("path");,
log.info(); 추가
src->main->resources 밑에 log4j2.xml 파일생성
ㄴlog4j2 xml 설정 코딩