如何使用play框架呈现简单的html页面? [英] How can I render a simple html page using play framework?
问题描述
这是一种使用Play Framework版本2呈现纯HTML文件的方法吗? 我不想将其放在public/文件夹中,因为稍后会向其中添加一些动态信息.
Is it a way to render a pure html file with play framework version 2? I don't want to put it in public/ folder because later on there will be some dynamic information added to it.
推荐答案
这是我的解决方案:
在路线中:我进行了以下一些配置.
in routes: I do some configurations as following.
GET /hello.html controllers.Assets.at(path="/public/html", file="hello.html")
GET /public/javascripts/jquery-1.9.0.min.js controllers.Assets.at(path="/public/javascripts", file="jquery-1.9.0.min.js")
GET /public/stylesheets/bootstrap.css controllers.Assets.at(path="/public/stylesheets", file="bootstrap.css")
,然后文件结构如下:
public->HTML->hello.html
public->javascripts->jquery-1.9.0.min.js
public->stylesheets->bootstrap.css
对于hello.html,这是其内容.
for hello.html , here is its content.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel='stylesheet' type='text/css' href='/public/stylesheets/bootstrap.css'>
</head>
<body>
<script src="/public/javascripts/jquery-1.9.0.min.js" type="text/javascript"></script>
</body>
</html>
完成这三个步骤后,您可以直接使用外部HTML.无需遵循Play模板即可进行前端开发工作. 因此,现在,Play只负责后端.前端开发人员只需操作此公共文件即可进行开发.
After these three steps, you can use outside HTML directly. No need to follow Play template to do front-end development work. So now, Play only is responsible for back-end. Front-end developer only needs to operate this public file to do development.
这篇关于如何使用play框架呈现简单的html页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!