【问题标题】:Mix regex and wildcard in struts2 struts.xml在 struts2 struts.xml 中混合正则表达式和通配符
【发布时间】:2012-11-02 13:26:59
【问题描述】:

按照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 配置中混合使用正则表达式和通配符吗?

【问题讨论】:

    标签: regex struts2 action-mapping


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-24
      • 2013-12-16
      • 2011-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-11
      • 1970-01-01
      相关资源
      最近更新 更多