1: 下載struts2 包(2.1.8.1):
struts-2.1.8.1-all:下面有四個子包apps,docs,lib,src.
2: struts2jar包:
從struts-2.1.8.1-all\struts-2.1.8.1\apps\struts2-blank-2.1.8.1\WEB-INF\lib中復(fù)制所有jar文件,它是最小的jar文件集合。
3:struts2參考手冊的使用:
struts-2.1.8.1-all/struts-2.1.8.1/docs/docs/guides.html
4:修改web.xml:
打開struts-2.1.8.1-all/struts-2.1.8.1/docs/docs/webxml.html文件,把如下內(nèi)容寫入web.xml.
struts-2.1.8.1-all:下面有四個子包apps,docs,lib,src.
2: struts2jar包:
從struts-2.1.8.1-all\struts-2.1.8.1\apps\struts2-blank-2.1.8.1\WEB-INF\lib中復(fù)制所有jar文件,它是最小的jar文件集合。
3:struts2參考手冊的使用:
struts-2.1.8.1-all/struts-2.1.8.1/docs/docs/guides.html
4:修改web.xml:
打開struts-2.1.8.1-all/struts-2.1.8.1/docs/docs/webxml.html文件,把如下內(nèi)容寫入web.xml.
<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>/*</url-pattern>
</filter-mapping>
5:建立struts.xml文件
從struts-2.1.8.1-all\struts-2.1.8.1\apps\struts2-blank-2.1.8.1\WEB-INF\classes把struts.xml文件復(fù)制到項目的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>
<!-- Add packages here -->
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="hello">
<result>
/hello.jsp
</result>
</action>
</package>
</struts>
6:在webroot下新建一個hello.jsp文件。
7:項目發(fā)布,在地址欄輸入http://localhost:端口名/項目名/hello.action,就可以看到效果了。