how to map an url like www.example.com?foo=bar

Splash Forums PrettyFaces Users how to map an url like www.example.com?foo=bar

This topic contains 2 replies, has 2 voices, and was last updated by  Christian Kaltepoth 4 years, 10 months ago.

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

    firedancer
    Participant

    How do I write a mapping for an url like ?foo=bar

    It is a callback redirect url from google oAuth2, which looks like a plain old url…

    I have to specify the redirect url, and google appends it with some key=value params in the plain old url style…

    I tried the patterns:

    pattern=”oauth2callback?foo=#{bean.foo}&?bar=#{bean.bar}”

    pattern=”oauth2callback/#{bean.foo}/#{bean.bar}”

    But these pattners doesn’t match the resulting url.

    #22844

    firedancer
    Participant

    Nevermind, I fixed it.

    In case someone else wonders how:

    I created pretty-config.xml with the following contents:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>

    <pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.2.0"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.2.0

    http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.2.0.xsd">

    <rewrite match="/oauth2callback?state=(w+)&code=(w+)" url="http://localhost:8080/mysite/oauth2callback/$1/$2"/>

    </pretty-config>

    #22845

    Hi,

    you could also declare the query parameters in your mapping like this:

    <url-mapping id="callback">
    <pattern value="/oauth2callback" />
    <view-id value="/faces/something.jsf" />
    <query-param name="state">#{bean.state}</query-param>
    <query-param name="code">#{bean.code}</query-param>
    </url-mapping>

    Christian

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

You must be logged in to reply to this topic.

Comments are closed.