新视图的编译问题.scala.html到.class

新视图的编译问题.scala.html到.class,scala,playframework,playframework-2.4,Scala,Playframework,Playframework 2.4,我不熟悉游戏框架。我试图按照一个示例编译我的play framework项目。当我编译这个示例时,它工作正常,并且在目标中编译了.scala.html视图,作为.class。我添加了一个新视图,但它没有编译到目标中。有什么建议可以解决这个问题吗?我试着用命令行编译activator,清理并重新构建项目,单独构建.scala.html,但没有一次成功。如何在Play 2.4中添加新视图并编译它 package controllers; import models.Client; import

我不熟悉游戏框架。我试图按照一个示例编译我的play framework项目。当我编译这个示例时,它工作正常,并且在目标中编译了.scala.html视图,作为.class。我添加了一个新视图,但它没有编译到目标中。有什么建议可以解决这个问题吗?我试着用命令行编译activator,清理并重新构建项目,单独构建.scala.html,但没有一次成功。如何在Play 2.4中添加新视图并编译它

package controllers;

import models.Client; 
import models.Server;
import models.TestEvent;
import models.TestPlan;

import play.data.Form;
import play.mvc.Controller;
import play.mvc.Result;
import views.formData.testFormData;

public class Application extends Controller {

// Default path request
// public Result index() {return ok(index.render("Your new application is ready."));}


/* Index Route Page
 * Returns the page where the form is filled with the arguments passed
 * Or an empty form if the id is 0
 */
public static Result getIndex(long id) {
    testFormData testData;
    // Find the corresponding index result to return (depends on the id)
    if(id == 0)
        testData = new testFormData();
    else
        testData = models.TestEvent.makeTestFormData(id);

    Form<testFormData> formData = Form.form(testFormData.class).fill(testData);
    return ok(index.render(formData,
            Client.getClientNameList(),
            Server.getServerNameList(),
            TestPlan.getTestPlanNameList()));
}


// Process a form submission
// Bind HTTP Post data to an instance of testFormData
// If errors are found, re-render the page displaying the error data
// If errors are not found, re-render the page displaying good data
public static Result postIndex() {
    // Retrieve the formData
    Form<testFormData> formData = Form.form(testFormData.class).bindFromRequest();

    // The retrieved formData has errors
    if(formData.hasErrors()) {
        return badRequest(index.render(formData,
                Client.getClientNameList(),
                Server.getServerNameList(),
                TestPlan.getTestPlanNameList()));
    }

    // The formData does not have errors
    else {
        // Convert the form data into a testEvent Instance
        TestEvent testEvent = TestEvent.makeTestEventInstance(formData.get());

        return ok(index.render(formData,
                Client.getClientNameList(),
                Server.getServerNameList(),
                TestPlan.getTestPlanNameList()));
    }
}
}

如果在编写代码时服务器未运行,则不会编译更改。您可以通过启用连续编译功能来解决这一问题,每次将更改写入文件系统时都会进行编译

为此:

启动激活器 使用~compile ~表示应立即编译更改


您可以对服务器执行类似的操作。使用~run,文件系统更改时会立即编译更改,并且不会延迟到浏览器刷新为止。

您的服务器正在运行吗?您是否有返回新创建视图的控制器操作?当您尝试从web浏览器调用控制器操作时,会得到什么结果?这还需要更改routes.conf。web浏览器上的错误是getIndex不是控制器的成员。Application on:GET/controllers.Application.getIndexid:Long?=0我将routes.conf配置为与Application.java文件中的操作相匹配。但是视图不在目标中。不要关心视图,可能是路由错误,也可能是控制器错误。控制器未被调用。视图是在需要时编译的,所以请首先尝试解决此问题。控制器就是问题所在。在我的IDE中,我得到的唯一错误是无法解析符号“index”,其中index是我的一个视图,这就是为什么我返回到视图问题。我试图导入视图,但它们也没有显示;不幸的是,同样的错误仍然存在。
GET     /                           controllers.Application.getIndex(id:Long ?= 0)

 POST    /                           controllers.Application.postIndex()



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