java
[WAS]struts2 간단 setting
gonGon
2008. 10. 2. 13:45
http://struts.apache.org/2.1.2/docs/simple-setup.html
struts를 가볍게 써보려고 하다가 필수 jar들이 생각이 안 나서 다시 찾았다.
struts2-core.jar
xwork.jar
ognl.jar
freemarker.jar
commons-logging.jar
web.xml
struts.xml
xwork.jar
ognl.jar
freemarker.jar
commons-logging.jar
web.xml
struts.xml
요렇게 파일은 필요하고
[service name]/WEB-INF/web.xml에는 아래와 같이 적는다.
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My Application</display-name>
<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>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My Application</display-name>
<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>
struts의 필터는 결국 request를 가로채고 uri의 String을 struts-config.xml의 action과 비교하여 dispatching하는 것 같다. url-pattern을 조작하면 특정 directory밑으로만 struts의 설정이 적용될 것이다.
다음은 struts confing인데 [service-name]/WEB-INF/classes/struts.xml 이다.
이름이 struts-config.xml에서 바뀐 것 같은데 바꿔서 작동하는 지는 시도해 보지 않았다. xml element쓰는 법이 바뀌었는지는 확인해 봐야겠다.
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts><!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
...
</package>
</struts>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts><!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
...
</package>
</struts>