Wildcard-6

The regular expression can also be in the form {FIELD_NAME:REGULAR_EXPRESSION}. The regular expression is a normal Java regular expression. For example:

<package name="books" extends="struts-default" namespace="/">
    <action name="/{type}/{author:.+}/list" class="example.ListBooksAction">
	<result>/books/list.jsp</result>
    </action>
</package>

In this example, if the url /philosophy/AynRand/list is requested, ListBooksAction's field "type" will be set to "philosophy" and "author" to "AynRand".

The matched groups can still be accessed using the {X} notation, like:

<package name="books" extends="struts-default" namespace="/">
    <action name="/books/{ISBN}/content" class="example.BookAction">
	<result>/books/{1}.jsp</result>
    </action>
</package>

猜你喜欢

转载自yaozuodaoforfly.iteye.com/blog/2084578