1

Is there any form to create subdirectories dynamically in playframework?, I was thinking in a common interceptor like spring, but.. how can I do it in play??

Thanks for any help

example.com/event1
example.com/event2
example.com/event3
curtisk
  • 19,950
  • 4
  • 55
  • 71
Javier Gutierrez
  • 549
  • 5
  • 16

2 Answers2

1

Best way, I think, is to use the routes file. Documentation here should be self-explanatory:

http://www.playframework.org/documentation/1.2.2/routes

(see e.g. http://www.playframework.org/documentation/1.2.2/routes#syntax)

cdegroot
  • 1,765
  • 11
  • 12
1

You can use the routes file, but be aware that the "name" of the folder must be a key that allows you to find the object. Usually the "key" will related to an entity, and in that case Play provides a Long id as key which is a better choice. After that key you can add some string for SEO-usability purposes.

So your routes would be something like:

example.com/1/event1
example.com/2/event2
example.com/3/event3

(or alternatively)

example.com/event/1
example.com/event/2
example.com/event/3

using a routes file like:

GET /{id}/{name}      MyController.getFolder

or

GET /event/{id}       MyController.getFolder

There are some questions around here (SO) on how to add the extra text to the path.

Pere Villega
  • 16,429
  • 5
  • 63
  • 100