-1

I am given one of two request URIs, and I do not know which one I will receive:

/?code=someAuthorizationCode&state=someState
/?error=someError&state=someState

I have used String[] redirectURIQueryParameters = exchange.getRequestURI().toString().split("[?/&]+"); to get the parameters and their corresponding values. Printing the string by ascending index results in an empty string, and then either code=someAuthorizationCode or error=someError, and then state=someState.

I understand that it is possible to determine the parameters returned and their corresponding values from the second string of the array onwards, but I am sure there is a cleaner way of doing so. What is the most efficient method of extracting the parameters from these URIs?

Thanks in advance.

1 Answers1

0

Use a Map as your parameter in your Controller and you will get them as key-value pairs.

Karthik PV
  • 78
  • 1
  • 1
  • 5