Move URL parameter position

Splash Forums PrettyFaces Users Move URL parameter position

This topic contains 2 replies, has 2 voices, and was last updated by  Lincoln Baxter III 7 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #17844


    I’ve tried many ways but still can’t figure out how to do the following. Could somebody give me a hand?

    What I want is:

    Browser URL input is*.*/*.jsf

    to be mapped to*.*/*.jsf?username=cutegirl

    I know if will work if I write a rule for every JSF file. Do I have to specify the JSF file one by one? Is there any convenient way to have a generic configuration?

    Thank you very much.


    Hey @trivial2k,

    You can use a global rewrite rule for something like this, notice you would need two rules, one rule if there are no incoming query parameters, and another rule if there are:

    <rewrite match="/^(cutegirl)(/.*/.*.jsf)$" substitute="$2?username=$1" />

    <rewrite match="/^(cutegirl)(/.*/.*.jsf?.*)$" substitute="$2&username=$1" />

    Which should do what you want:$1)($2/*.*/*.jsf) ->*.*/*.jsf?username=cutegirl

    I haven’t tested these specific rules, but they would look something like what I have written, using regular expressions:

    This is equivalent to:

    String newURL = ((String) request.getURI() + "?" + request.getQueryString()).replaceAll(match, substitute);

    You can read more about regular expressions here:


    I should add that you are correct, the ‘cleaner’ way to do this would be to write a url-mapping for each page on which you wish to perform the operation.

    There is currently no way to specify a global url-mapping, however, perhaps the parent URL-mapping functionality would be of interest:

    The problem with global mappings is that they are not in fact a true mapping, they are more of a rewrite rule. It may however be beneficial to support the url/pattern/#{param} syntax in rewrite rules. I will add an issue for this:

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Comments are closed.