how to use “war.context” in Configuration file of Play Framework ?

Take a look at this thread on the Google Groups for a description of what you are asking.

http://groups.google.com/group/play-framework/browse_thread/thread/b4783c821fd29898?pli=1

In essence, what it is saying, is.

In your application.conf file, you set a property such as

war.context=/MyAppName

Then, in your routes file, you set it up to include your WAR context in the following way

# Set context name 
%{ ctx = play.configuration.getProperty('war.context', '') }% 

# Routes 
# This file defines all application routes (Higher priority routes first) 
# ~~~~ 
# Home page 
GET     ${ctx}/                                      Application.index 
# Map static resources from the /app/public folder to the /public path 
GET     ${ctx}/public/                               staticDir:public 
# Catch all 
*       ${ctx}/{controller}/{action}                 {controller}.{action} 

You can see therefore, whatever you place in your war.context, you can then put into your routes to pick up the correct path.

Leave a Comment