有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

我正在寻找一些使用Play框架将Polymer与服务器端Scala/java结合使用的帮助

我正在用Play框架在scala项目中尝试聚合物。我在https://www.polymer-project.org/docs/start/creatingelements.html开始学习。在我的索引中。斯卡拉。html我已经包含了我的元素。html并尝试访问我的元素。我没有像预期的那样在元素中看到我的内容。任何关于我尝试做的事情是否可行的建议。先谢谢你

在Mac上,在IntelliJ中创建了一个play java应用程序

  1. https://www.playframework.com/download安装了最新的play framework 2.3.7
  2. 解压缩zip文件并运行activator命令activator new以创建新项目
  3. 打开Intellij IDEA并导入新项目
  4. 通过激活器运行项目

代码附在下面

octo元素。html:

<link rel="import" href="../bower_components/polymer/polymer.html">
<polymer-element name="octo-element" noscript>
    <template>
       <span>Hello from <b>octo-element</b>. This is my Shadow DOM.</span>
</template>
</polymer-element>

索引。斯卡拉。html

@(message: String)
@main("Welcome to Play") {

@message
<octo-element></octo-element>
}

main。斯卡拉。html @(标题:字符串)(内容:Html)

<!DOCTYPE html>

<html>
<head>
    <title>@title</title>
    <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
    <link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
    <script src="@routes.Assets.at("javascripts/hello.js")" type="text/javascript"></script>
        <!-- 1. Load platform support before any code that touches the DOM. -->
    <script src="../../bower_components/webcomponentsjs/webcomponents.min.js"></script>
        <!-- 2. Load the component using an HTML Import -->
    <link rel="import" href="../../bower_components/elements/octo-element.html">
</head>
<body>
    @content
</body>
</html>

应用程序。java

package controllers;

import play.mvc.Controller;
import play.mvc.Result;
import views.html.index;

public class Application extends Controller {

public static Result index() {
    return ok(index.render("Your new application is ready."));
}

}

共 (1) 个答案

  1. # 1 楼答案

    聚合物组件(html和java脚本)应在资产下创建。资源路由在路由配置中定义