struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JBL <>
Subject Re: Struts 2 URL parameters lost
Date Mon, 06 Aug 2007 20:49:44 GMT

Final answer: we implemented a custom ActionMapper that handles a URL string
that doesn't involve a ? to separate the query parameters. Stuck a reference
to it in


Building a new ActionMapper isn't terribly difficult. It helps to define
your expected URLs with a regular expression, then use a precompiled
pattern. Ours looks something like:

private static String NAMESPACE_REGEX = "...";
private static String ACTION_REGEX = "...";
private static String METHOD_REGEX = "...";
private static String PARAMS_REGEX = "...";

private static String URI_REGEX = (concatenate the four above)

private static Pattern URI_PATTERN = Pattern.compile(URI_REGEX);

Then, in getMapping(), pull out the URI (similar to DefaultActionMapper) and

Matcher m = URI_PATTERN.matcher(uri);

If you get a match, create a new ActionMapping and set its components based
on the matching groups:



You can parse the parameter section and build a map to pass to

Using a precompiled pattern may or may not be the most efficient possible
solution, but it helps you define exactly what URIs you expect. I recommend
throwing a bunch of possibilities at it in your unit test code with various
components present and missing. If you're a little unsure about regular
expressions, build some unit tests for those, too. Sun has a decent write-up
in their Java documentation:

Especially read the "Groups and Capturing" section, it's a handy tool to
have in your portfolio.

We may yet discover why we couldn't get query parameters, but this works for
now. Good luck.
View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message