<pre name="code" class="html">
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- 多包但唯一 -->
<package name="default" namespace="/" extends="struts-default">
<!-- 友好页面 要三个通配符 -->
<default-action-ref name="index"></default-action-ref>
<action name="index">
<result>/jsp/error.jsp</result>
</action>
<!--1 指定metho方法 页面调用http://localhost:8080/HelloWorld/addAction.action-->
<action name="addAction" method="add" class="com.imooc.action.HelloWorldAction">
<result>/jsp/add.jsp</result>
</action>
<action name="updateAction" method="update" class="com.imooc.action.HelloWorldAction">
<result>/jsp/update.jsp</result>
</action>
<!--2感叹号方式要配置的文件 页面调用http://localhost:8080/HelloWorld/helloworld!add.action 不推荐-->
<action name="helloworld" class="com.imooc.action.HelloWorldAction">
<result>/jsp/result.jsp</result>
<result name="addAction">/jsp/add.jsp</result>
<result name="updateAction">/jsp/update.jsp</result>
</action>
<!-- 3动态调用(通配符) 页面调用http://localhost:8080/HelloWorld/HelloWorld_add_action.action-->
<!-- action name="*_*_*" method="{2}" class="com.imooc.{3}.{1}Action">(*_*_*)ye可调用默认action,两个通配符有冲突(*_*)
<result>/result.jsp</result>
<result name="add">/{2}.jsp</result>
<result name="updateAction">/{2}.jsp</result></action>
-->
<!-- 页面调用http://localhost:8080/HelloWorld/helloworld_add.action 推荐-->
<action name="helloworld_*" method="{1}" class="com.imooc.action.HelloWorldAction">
<result>/jsp/result.jsp</result>
<result name="addAction">/jsp/{1}.jsp</result>
<result name="updateAction">/jsp/{1}.jsp</result>
</action>
</package>
<!-- 隐藏后缀名 1.web.xml配置2.struts.xml配置3.struts.properties配置 优先级递减-->
<constant name="struts.action.extension" value="do,html,xml"></constant>
<!-- 感叹号方式要配置的文件 页面调用www.http://localhost/HellWorld/hellowodl-->
<constant name="struts.enable.DynamicMethodInvocation" value="flase"></constant>
</struts>