public class RegexPatternMatcher extends Object implements PatternMatcher<RegexPatternMatcherExpression>
Allows regular expressions to be used in action names. The regular expressions can be in the form {FIELD_NAME} or {FIELD_NAME:REGULAR_EXPRESSION}. For example:
<action name="/{bio:.+}/test/{name}" class="org.apache.struts2.showcase.UITagExample">
<result>/tags/ui/example.jsp</result>
</action>
For this to work it is important to set the following:
<constant name="struts.enable.SlashesInActionNames" value="true"/> <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/> <constant name="struts.patternMatcher" value="regex" />
| Constructor and Description |
|---|
RegexPatternMatcher() |
| Modifier and Type | Method and Description |
|---|---|
RegexPatternMatcherExpression |
compilePattern(String data)
Translate the given
String into an object
representing the pattern matchable by this class. |
boolean |
isLiteral(String pattern)
Determines if the pattern is a simple literal string or contains wildcards that will need to be processed
|
boolean |
match(Map<String,String> map,
String data,
RegexPatternMatcherExpression expr)
Match a pattern against a string
|
public RegexPatternMatcherExpression compilePattern(String data)
PatternMatcher Translate the given String into an object
representing the pattern matchable by this class.
compilePattern in interface PatternMatcher<RegexPatternMatcherExpression>data - The string to translate.public boolean isLiteral(String pattern)
PatternMatcherisLiteral in interface PatternMatcher<RegexPatternMatcherExpression>pattern - The string patternpublic boolean match(Map<String,String> map, String data, RegexPatternMatcherExpression expr)
PatternMatchermatch in interface PatternMatcher<RegexPatternMatcherExpression>map - The map to store matched valuesdata - The string to matchexpr - The compiled wildcard expressionCopyright © 2000–2017 Apache Software Foundation. All rights reserved.