Klaus Schulz
Klaus Schulz

Reputation: 557

URL Parameter and routing configuration

I stumble upon a little detail and just want to be sure I don't miss something obvious.

If I define a route like this:

GET    /Program                     controllers.MyProgram.method(program ?= null)

The parameter passed via

http://localhost:9000/Program?program=MyProgram

is MyProgram

However, I would rather define a route like this:

GET    /Program:program             controllers.MyProgram.method(program)

But then the parameter passed via

localhost:9000/Program:MyProgram

is :MyProgram.

How can I get rid of the : in front of the parameter?

Of course, I could delete it by hand with Java/Scala but that feels like I am doing something wrong...

Upvotes: 0

Views: 50

Answers (2)

Sivakumar
Sivakumar

Reputation: 1751

I think you need to separate your path with param by / in your routes E.G: /Program/:program By this way, you can avoid colon as prefix in your param received in your Action method.

Upvotes: 0

ed.
ed.

Reputation: 2706

You're going to have to add a regex for the colon:

GET /Program$colon<\:>:program       controllers.MyProgram.method(colon, program)

The downside is that you have a redundant parameter coming in to your Action.

See: this answer

Upvotes: 1

Related Questions