---
title: "Struts的通配符方式"
author: "standfox"
date: "2008-08-29T12:15:47Z"
tags: []
slug: "struts"
draft: false
lastmod: "2008-08-29T12:15:47Z"
id: 234375
url: "https://standfox.iteye.com/blog/234375"
---

解释通配符的最好方法是来看一个例子：

<action
path="/edit*"
type="org.apache.struts.webapp.example.Edit{1}Action"
name="{1}Form"
scope="request"
validate="false">
<forward
name="failure"
path="/mainMenu.jsp"/>
<forward
name="success"
path="/{1}.jsp"/>
</action>

在path属性中的*号可以匹配请求URI/editSubscription,, editRegistration和其他任何以/edit开头的URI，但/editSubscription/add将不会被匹配。被匹配的部分将会替换AtionMapping的属性和转向（Forward）中的{1}。

通配符可以包含如下特殊字符：

*　 匹配零个或多个字符但不包括/

**　匹配零个或多个字符串并且包括/

\character　　反斜杠字符串是转义字符。