이클립스가 설치 되어 있다는 전재 하에 진행 한다.
==> struct 2 다운받기
http://struts.apache.org/download.cgi?Preferred=http%3A%2F%2Fmirror.korea.ac.kr%2Fapache
2010. 01. 08 기준으로 struct 2 최신 버전 임.
3번 째 struct-2.1.8.1-lib.zip 파일을 다운 받는다. 별 이유 없으며, 라이브러리 파일만
사용하기 위해서 선택 함 .
- struts-2.1.8.1-all.zip (110mb) [PGP] [MD5]
- struts-2.1.8.1-apps.zip (34mb) [PGP] [MD5]
- struts-2.1.8.1-lib.zip (11mb) [PGP] [MD5]
- struts-2.1.8.1-docs.zip (60mb) [PGP] [MD5]
- struts-2.1.8.1-src.zip (20mb) [PGP] [MD5]
압축을 풀면 라이브러리 가 보이며, 다 필요 한 것은 아니다.
struct에서 기본적으로 필요한 아래 일 들만 eclips에 include 하자.
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
freemarker-2.3.15.jar
ognl-2.7.3.jar
struts2-core-2.1.8.jar
xwork-core-2.1.6.jar
위의 파일들을 WebContent/WEB-INF/lib 에 복사를 한다.
filter 등록(WebContent\WEB-INF/web.xml 파일 수정)
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>jsp</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/struts/*</url-pattern>
</filter-mapping>
</web-app>
2.x 버전 부터 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
로 수정 되었음
자세한 내용은
http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html
확인 할 수 있으며, 삽질 방지를 위해서 꼭 확인 해야 한다.
sruts.xml , struts.properties생성
파일은 Eclips 의 src 폴더에 생성 한다.
struts.xml 내용
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default" namespace="">
<action name="main">
<result>/index.jsp</result>
</action>
</package>
</struts>
struts.properties내용
truts.i18n.reload=true
struts.devMode = false
struts.configuration.xml.reload=true
struts.continuations.package = org.apache.struts2.showcase
struts.custom.i18n.resources=globalMessages
#struts.action.extension=jspa
struts.url.http.port = 8080
#struts.freemarker.manager.classname=customFreemarkerManager
struts.serve.static=true
struts.serve.static.browserCache=false
struts.multipart.maxSize=2097252
*.src 폴더에 파일들을 생성 하면 컴파일 시
WebContent/WEB-INF/classes 하위에 생성 된다.
* 마지막으로 2.0 이전 버전과 최신 버전인 2.1.8에서 설정시 차의 점은
필터가 변경 되었다느게 가장 중요 하다.. 꼭 릴리스 노트를 확인 해 봐야 한다.