[html] <?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> <!-- 定義一個常量 --> <!--<constant name="struts.devMode" value="true" />--> <package name="front" extends="struts-default" namespace="/front"> <action name="index"> <result>/Namespace.jsp</result> </action> </package> <package name="main" extends="struts-default" namespace="/main"> <action name="index" class="Test"> <result name="main">/Namespace.jsp</result> </action> </package> </struts> www.2cto.com <span style="font-family:Arial;BACKGROUND-COLOR: #ffffff">解釋說明:package相當於java包的作用,struts.xml中可以存在多個不同名的package,</span> [html] <span style="font-family:Arial;BACKGROUND-COLOR: #ffffff">extends相當於java中的繼承,這裡繼承的是系統自帶的struts-default.xml文件,</span> [html] <span style="font-family:Arial;BACKGROUND-COLOR: #ffffff">namespace是訪問路徑,例如<a href="http://127.0.0.1:8080/">http://127.0.0.1:8080/</a>項目名稱/main/,</span> [html] <span style="font-family:Arial;BACKGROUND-COLOR: #ffffff">action 對應就是具體訪問的Action類別名,class後面跟的就是具體action類,</span> [html] <span style="font-family:Arial;BACKGROUND-COLOR: #ffffff">result 是具體Action類返回的String值,默認是success(實際上是execute方法返回的值)</span> [html] <span style="font-family:Arial;BACKGROUND-COLOR: #ffffff"></span>