Home >Web Front-end >HTML Tutorial >Assets Understanding Essay_html/css_WEB-ITnose

Assets Understanding Essay_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:55:181105browse

Apply in PlayFramework

What is provided in Play Framework are dynamic file responses, and most of the front-end work content is static files. Assets probably plays this role.

See conf/routes for the default path:

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

#The comment is to the effect that the static file is from the /public folder to the URL path in /assets .

The rule declares that HTTP GET request /assets/ is mapped to the Controllers.Assets.at method. This method uses two parameters to tell the method Path path and file file.

Default use /public/filename path, if you need to specify details, you can define routing rules:

GET     /images/*file                 controllers.Assets.at(path="/public/images", file)GET     /styles/*file                 controllers.Assets.at(path="/public/styles", file)

Use assets reverse routing to avoid hardocded (hard-coded [Baidu Encyclopedia entry]) URL, Assets.at is also a common Action method, so you can use assets reverse routing, for example:

<link href="@routes.Assets.at("images/favicon.png")" rel="shortcut icon" type="image/png">

In addition to the advantages of reverse routing, use Another advantage of the Asset controller is the built-in caching support and support for Http Entity Tag (Etag). This allows the client to request resources from the server or use files in Cached as needed.

Assets This is developed from rails, you can read the introduction in [Ruby-China].

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn