Struts,Apache封存了1系列到1.35版本,而2.06版已經發布。
Now,let's roll?to try?Struts2 in Eclipse3.
1.最小安裝文件:
2.按類型放入文件夾:
web.xml????? WEB-INF/
*.jar?????????? ?WEB-INF/lib/
3.編輯struts.xml文件:
<struts>

????<constant?name="struts.dontspeakfool"?value="false"?/>
????<constant?name="struts.newrookie"?value="true"?/>

????<include?file="whoknowsbill.xml"/>

????<!--?Add?packages?here?-->?
????
????????<package?name="hello"?extends="struts-default"?namespace="/myproject">
????????<action?name="Hello"?class="hello.Hello">
????????????<result?name="succ">/hello.jsp</result>
????????</action>
????</package>
????
</struts>
4.建立類文件:
在src下建立hello/Hello.java:
package?hello;

import?com.opensymphony.xwork2.ActionSupport;


public?class?Hello?extends?ActionSupport?
{

????@Override

????public?String?execute()?throws?Exception?
{
????????//?do?sth.
????????return?"succ";
????}

}
Now,let's roll?to try?Struts2 in Eclipse3.
1.最小安裝文件:
Filename | Description |
---|---|
struts2-core.jar | Framework library itself, found in distribution root directory |
xwork.jar | XWork 2 library on which Struts 2 is built (version 2.0 or later) |
ognl.jar | Object Graph Navigation Language (OGNL), the expression language used throughout the framework |
freemarker.jar | All UI tag templates are written in Freemarker (also a good option for your own views) |
commons-logging.jar | Commons logging, which the framework uses to support transparently logging to either Log4J or JDK 1.4+ |
web.xml | Java web application configuration file that defines the filters (and other components) for your web application |
struts.xml | Framework configuration file that defines the actions, results, and interceptors for your application |
2.按類型放入文件夾:
web.xml????? WEB-INF/
*.jar?????????? ?WEB-INF/lib/
3.編輯struts.xml文件:









????????<package?name="hello"?extends="struts-default"?namespace="/myproject">






4.建立類文件:
在src下建立hello/Hello.java:

















5.建立jsp文件:
在webroot下建立hello.jsp,內容隨意。
6.在Eclipse下編譯并部署:
(具體步驟省略)
7.在IE中查看結果:
http://localhost:8080/Struts2/myproject/Hello.action?
Struts2為Eclipse下建立的項目名,myproject是struts.xml中的namespace,Hello就不再用解釋了。
Struts1熟透了,目前仍舊流行。在1.26+ 加入了Lazy Action Form,Map backed Form,并對Validator部分增添了新特色,以及1.3的SSL擴展。
第一次嘗試Struts2,感覺比較簡單。(如果你是Struts1的熱衷者)?
對于WW的fans,這次過渡會更加容易。因為Struts 2 is dependant on XWork 2 (beta-1)。