2

按照http://struts.apache.org/2.2.3/docs/wildcard-mappings.html,下面的配置工作

通配符作品

<action name="/drill/*" class="example.DrillAction" method="{1}">
    <result name="success" type="freemarker">/drill-{1}.ftl</result>
</action>

正则表达式也可以

<action name="/{group}/drill/index" class="example.DrillAction" method="index">
    <result name="success" type="freemarker">/drill-index.ftl</result>
</action>

但我未能在操作配置中混合通配符和正则表达式,如下所示:

<action name="/{group}/drill/*" class="example.DrillAction" method="{1}">
    <result name="success" type="freemarker">/drill-{1}.ftl</result>
</action>

当我访问 http-path-to-host/ rs6k/drill/index时,会发生404错误:There is no Action mapped for namespace [/] and action name [rs6k/drill/index] associated with context path [].

我可以在 struts.xml 配置中混合正则表达式和通配符吗?

4

1 回答 1

1

您确定您已阅读有关通配符映射的所有内容吗?

<action name="/{group}/drill/{some}" class="example.DrillAction" method="{2}">
  <result name="success" type="freemarker">/drill-{2}.ftl</result>
</action>
于 2012-11-02T13:45:34.000 回答