4,511,447 th visitor since 2017.2.1 ( Today : 2014 )
Programming
No. 490
Name. swindler
Subject. struts config - wildcard 사용
Main Cate. Java
Sub Cate.
Date. 2008-11-03 11:34
Hit. 4515 (210.182.190.136)
File.
4.10 Using Wildcards in ActionMappings

[Since Apache Struts 1.2.0] As an application grows in size, so will the number of action mappings. Wildcards can be used to combine similar mappings into one more generic mapping.

The best way to explain wildcards is to show an example and walk through how it works. This example modifies the previous mapping in the ActionMapping Example section to use wildcards to match all pages that start with /edit:

<!-- Generic edit* mapping -->
<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>

The "*" in the path attribute allows the mapping to match the request URIs /editSubscription, editRegistration, or any other URI that starts with /edit, however /editSubscription/add would not be matched. The part of the URI matched by the wildcard will then be substituted into various attributes of the action mapping and its action forwards replacing {1}. For the rest of the request, the framework will see the action mapping and its action forwards containing the new values.

Mappings are matched against the request in the order they appear in the framework's configuration file. If more than one pattern matches the last one wins, so less specific patterns must appear before more specific ones. However, if the request URL can be matched against a path without any wildcards in it, no wildcard matching is performed and order is not important.

Wildcard patterns can contain one or more of the following special tokens:

* Matches zero or more characters excluding the slash ('/') character.
** Matches zero or more characters including the slash ('/') character.
\character The backslash character is used as an escape sequence. Thus \* matches the character asterisk ('*'), and \\ matches the character backslash ('\').

In the action mapping and action forwards, the wildcard-matched values can be accessed with the token where N is a number from 1 to 9 indicating which wildcard-matched value to substitute. The whole request URI can be accessed with the token.

The action mapping attributes that will accept wildcard-matched strings are:

attribute
catalog
command
forward
include
input
multipartClass
name
parameter
prefix
roles
suffix
type
Also, the action mapping properties (set using the <set-property key="foo" value="bar"> syntax) will accept wildcard-matched strings in their value attribute.
The action forward attributes that will accept wildcard-matched strings are:

catalog
command
path
Like the action mapping, the action forward properties (set using the <set-property key="foo" value="bar"> syntax) will accept wildcard-matched strings in their value attribute.





[바로가기 링크] : http://coolx.net/cboard/develop/490



swindler 출처 : struts userGuide
http://struts.apache.org/1.x/userGuide/building_controller.html
2008-11-03
Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog