FAQ

[play-framework] [2.1-scala] Javascript router: 404 ?

Edmondo1984
Apr 8, 2013 at 8:21 am
Dear all,
I have the following problem when trying to use the Javascript router in
play:

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET / controllers.Application.index

GET /config controllers.Configuration.configuration

POST /config
controllers.Configuration.updateConfiguration

# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public",
file)

GET /assets/javascripts/routes
  controllers.Application.javascriptRoutes

object Application extends Controller {

   def index = Action {
     Ok(views.html.index("Your new application is ready."))
   }

   def javascriptRoutes = Action { implicit request =>
     import routes.javascript._
     Ok(
       Routes.javascriptRouter("jsRoutes")(
        Configuration.configuration,
        Configuration.updateConfiguration
       )
     ).as("text/javascript")
   }

}

Everything works fine, but when I include the following snippet:

<script type="text/javascript"
src="@routes.Application.javascriptRoutes"></script>

This yields:

    1. Request URL:
    http://localhost:9000/assets/javascripts/routes
    2. Request Method:
    GET
    3. Status Code:
    404 Not Found


Where am I wrong?

Thank you for your help
Edmondo

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
reply

Search Discussions

2 responses

  • Julien Richard-Foy at Apr 8, 2013 at 8:59 am
    Move the route definition of the javascript router action above the assets
    route.

    On Tue, Apr 2, 2013 at 9:53 AM, edmondo1984 wrote:

    Dear all,
    I have the following problem when trying to use the Javascript router in
    play:

    # Routes
    # This file defines all application routes (Higher priority routes first)
    # ~~~~

    # Home page
    GET / controllers.Application.index

    GET /config controllers.Configuration.configuration

    POST /config
    controllers.Configuration.updateConfiguration

    # Map static resources from the /public folder to the /assets URL path
    GET /assets/*file controllers.Assets.at(path="/public",
    file)

    GET /assets/javascripts/routes
    controllers.Application.javascriptRoutes

    object Application extends Controller {

    def index = Action {
    Ok(views.html.index("Your new application is ready."))
    }

    def javascriptRoutes = Action { implicit request =>
    import routes.javascript._
    Ok(
    Routes.javascriptRouter("jsRoutes")(
    Configuration.configuration,
    Configuration.updateConfiguration
    )
    ).as("text/javascript")
    }

    }

    Everything works fine, but when I include the following snippet:

    <script type="text/javascript"
    src="@routes.Application.javascriptRoutes"></script>

    This yields:

    1. Request URL:
    http://localhost:9000/assets/javascripts/routes
    2. Request Method:
    GET
    3. Status Code:
    404 Not Found


    Where am I wrong?

    Thank you for your help
    Edmondo

    --
    You received this message because you are subscribed to the Google Groups
    "play-framework" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to play-framework+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "play-framework" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Luigi Antonini at Aug 2, 2013 at 3:39 am
    I've same problem , have you solved ?

    Il giorno lunedì 8 aprile 2013 10:59:16 UTC+2, Julien Richard-Foy ha
    scritto:
    Move the route definition of the javascript router action above the assets
    route.


    On Tue, Apr 2, 2013 at 9:53 AM, edmondo1984 <edmond...@gottexbrokers.com<javascript:>
    wrote:
    Dear all,
    I have the following problem when trying to use the Javascript router in
    play:

    # Routes
    # This file defines all application routes (Higher priority routes first)
    # ~~~~

    # Home page
    GET / controllers.Application.index

    GET /config controllers.Configuration.configuration

    POST /config
    controllers.Configuration.updateConfiguration

    # Map static resources from the /public folder to the /assets URL path
    GET /assets/*file controllers.Assets.at(path="/public",
    file)

    GET /assets/javascripts/routes
    controllers.Application.javascriptRoutes

    object Application extends Controller {

    def index = Action {
    Ok(views.html.index("Your new application is ready."))
    }

    def javascriptRoutes = Action { implicit request =>
    import routes.javascript._
    Ok(
    Routes.javascriptRouter("jsRoutes")(
    Configuration.configuration,
    Configuration.updateConfiguration
    )
    ).as("text/javascript")
    }

    }

    Everything works fine, but when I include the following snippet:

    <script type="text/javascript"
    src="@routes.Application.javascriptRoutes"></script>

    This yields:

    1. Request URL:
    http://localhost:9000/assets/javascripts/routes
    2. Request Method:
    GET
    3. Status Code:
    404 Not Found


    Where am I wrong?

    Thank you for your help
    Edmondo

    --
    You received this message because you are subscribed to the Google Groups
    "play-framework" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to play-framewor...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "play-framework" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post