<?xml version= "1.0" encoding ="UTF-8"?>
<web-app id= "WebApp_9" version ="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list >
<welcome-file> index.jsp</welcome-file >
<welcome-file> index.html</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> /*</ url-pattern>
</filter-mapping >
<!-- ... -->
</web-app>
<?xml version= "1.0" encoding ="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- 聲明包 -->
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<package name="myPackage" extends= "struts-default" namespace="/" >
<!-- 定義action -->
<action name="first" >
<!-- 定義處理成功後的返回界面 -->
<result> first.jsp</result >
</action >
</package >
</struts>
第五步:測試。在index.jsp中加入一個鏈接,調用action
<body>
< a href ="first.action">經過struts框架 </a>
</body>
建立first.jsp
<body>
<h1> 這是經過struts框架過來的 </h1>
</body>