https://archive.apache.org/dist/struts/binaries/ 에서 struts-2.0.14-all.zip 파일을 내려받는다.(엄청 오래 걸림 -_-;;)
![clip_image001[4] clip_image001[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0014.png)
- commons-logging-1.0.4.jar
- freemarker-2.3.8.jar
- ognl-2.6.11.jar
- struts2-core-2.0.14.jar
- xwork-2.0.7.jar
파일을 미리 다른 곳에 빼놓는다.
![clip_image002[4] clip_image002[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0024.png)
Dynamic Web Project 만들기
![clip_image003[4] clip_image003[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0034.png)
이름을 적고, 다음
![clip_image004[4] clip_image004[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0044.png)
web.xml 만들기
![clip_image005[4] clip_image005[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0054.png)
/WebContent/WEB-INF/lib 폴더에 위에서 선택한 파일을 붙여 넣는다.
![clip_image006[4] clip_image006[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0064.png)
web.xml에 필터를 등록함.
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 31 32 33 34 35 36 37 38 39 | <? xml version = "1.0" encoding = "UTF-8" ?> < web-app xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns = "http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation = "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id = "WebApp_ID" version = "3.1" > < display-name >HelloWorld</ display-name > < welcome-file-list > < welcome-file >index.html</ welcome-file > < welcome-file >index.htm</ welcome-file > < welcome-file >index.jsp</ welcome-file > < welcome-file >default.html</ welcome-file > < welcome-file >default.htm</ welcome-file > < welcome-file >default.jsp</ welcome-file > </ welcome-file-list > < filter > < filter-name >struts2</ filter-name > < filter-class >org.apache.struts2.dispatcher.FilterDispatcher</ filter-class > </ filter > < filter-mapping > < filter-name >struts2</ filter-name > < url-pattern >/*</ url-pattern > </ filter-mapping > </ web-app > |
![clip_image007[4] clip_image007[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0074.png)
이번에는 새 클래스 만들기
![clip_image008[4] clip_image008[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0084.png)
대충 적어 준다.
![clip_image009[4] clip_image009[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0094.png)
코드를 작성함.
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 | package happy.ch02.example01; //POJO(자바 빈즈) public class HelloWorld { // 아래 3 문장은 읽기 전용 프로퍼티 private String message; // 객체의 프로퍼티에 직접 접근 못함 public String getMessage() { // 읽기 전용을 위해 getter만 정의 return message; // 간접적으로 사용 } // 액션 메소드(기본적으로 execute란 이름을 사용한 public String execute() throws Exception { this .message = "Hello, World!" ; // 비즈니스 로직 return "success" ; // 리절트 코드 } } |
![clip_image010[4] clip_image010[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0104.png)
이번에는 Other 파일을 만듦.
![clip_image011[4] clip_image011[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0114.png)
XML 파일
![clip_image012[4] clip_image012[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0124.png)
src 폴더에 만든다.
![clip_image013[4] clip_image013[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0134.png)
struts.xml 이라는 이름으로, 위와 같이 작성
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <! DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" < struts > < package name = "example01" extends = "struts-default" > < action name = "HelloWorld" class = "happy.ch02.example01.HelloWorld" > < result name = "success" >/HelloWorld.jsp</ result > </ action > </ package > </ struts > |
![clip_image014[4] clip_image014[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0144.png)
이 위치다.(잘못 파일을 지워서 프로젝트를 새로 생성함 ㅠㅠ)
![clip_image015[4] clip_image015[4]](http://archmond.net/wp-content/uploads/2016/11/clip_image0154.png)
이번에는 JSP 파일. ${message}만 살아 있으면 된다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <! DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> < html > < head > < meta http-equiv = "Content-Type" content = "text/html; charset=UTF-8" > < title >Insert title here</ title > </ head > < body > < h1 >${message}</ h1 > </ body > </ html > |

드디어 된다 ㅠㅠ
(이 화면을 보기까지 1시간 걸림)