2016-03-09 48 views
0

當我嘗試編譯我的遊戲框架2.4的項目,我收到此錯誤:播放框架編譯錯誤:預期}但EOF發現

`}' expected but eof found. 
In /Users/dylhunn/Documents/workspace/my-project/app/controllers/Application.java 

這似乎表明,我卻辜負了我的牙套。但是,大括號實際上是正確匹配的,並且即使添加了額外(任意數量)的大括號大括號時,錯誤仍然存​​在。

我已經嘗試過「激活清潔」。

這裏是我的Application.java:

package controllers; 

import model.UserAccountManager; 
import play.data.Form; 
import play.libs.Json; 
import play.mvc.*; 
import harmony.core.Harmonizer; 

import play.twirl.api.Content; 
import views.html.*; 

import java.net.URLDecoder; 
import java.util.*; 

import static play.data.Form.form; 

public class Application extends Controller { 

    public Result index() { 
     if (validSessionIsActive()) return harmonizepage(); 
     else return landing(); 
    } 

    public Result about() { 
     Content html = views.html.auxtemplate.render("title", "content"); 
     return ok(html); 
    } 

    public Result contact() { 
     Content html = views.html.auxtemplate.render("title", "content"); 
     return ok(html); 
    } 

    public Result landing() { 
     return ok(views.html.landing.render(form(Credentials.class))); 
    } 

    public Result login(String message) { 
     if (validSessionIsActive()) return index(); 
     if (message == null) message = ""; 
     return ok(views.html.loginpage.render(Form.form(Credentials.class), message)); 
    } 

    public Result logout() { 
     String user = session("user-email"); 
     session().clear(); 
     if (user == null) return login("You were not logged in."); 
     return login("User " + user + " has been logged out."); 
    } 

    public Result harmonizepage() { 
     if (!validSessionIsActive()) return login("Please sign in to acess this page."); 
     return ok(views.html.harmonize.render()); 
    } 

    public Result testRegister() { 
     return ok(views.html.signuppage.render(Form.form(UserData.class)); 
    } 

    public static class Credentials { 
     public String email; 
     public String password; 
    } 

    public static class UserData { 
     public String email; 
     public String password; 
     public String name; 
     public String location; 
     public String birthday; 
    } 

    public Result loginSubmit() { 
     Form<Credentials> loginForm = form(Credentials.class).bindFromRequest(); 
     if (UserAccountManager.userRegistered(loginForm.get().email)) { 
      if (UserAccountManager.authenticate(loginForm.get())) { // success 
       session("user-email", loginForm.get().email); 
       return harmonizepage(); 
      } else { // Incorrect password 
       return login("Incorrect password for that email address."); 
      } 
     } else { // New user 
      session("candidate-email", loginForm.get().email); 
      session("candidate-password", loginForm.get().password); 
      session("registration-in-progress", "true"); 
      return login("Sorry -- signups are still closed!"); 
     } 
    } 

    public Result signupSubmit() { 
     if (!session("registration-in-progress").equals("true")) return login(""); 
     session("registration-in-progress", "false"); 
     Form<UserData> suForm = form(UserData.class).bindFromRequest(); 
     UserData data = suForm.get(); 
     data.email = session("candidate-email"); 
     data.password = session("candidate-password"); 

     UserAccountManager.registerUser(data); 

     return index(); 
    } 

    /** 
    * Checks the session cookie to see if a valid username is stored there. 
    */ 
    public static boolean validSessionIsActive() { 
     String email = session("user-email"); 
     return UserAccountManager.userRegistered(email); 
    } 

    public Result harmonize(String input) { 
     if (!validSessionIsActive()) 
      return badRequest("No user is currently signed in. Try closing and reopening the site"); 
     try { 
      input = URLDecoder.decode(input, "UTF-8"); 
     } catch (Exception e) { 
      return badRequest("The server received an unsupported URL encoding."); 
     } 
     List<String> inputChords = Arrays.asList(input.split(" ")); 
     List<List<String>> result = new ArrayList<>(); 
     String str = ""; 
     for (String s : inputChords) str = str + s + " "; 
     try { 
      result = Harmonizer.harmonize(str); 
     } catch (Exception e) { // Harmonizing failed for some reason 
      return badRequest(e.getMessage()); 
     } 
     return ok(Json.toJson(result)); 
    } 
} 
+0

清理項目並重建它。並且在文件 – mmuzahid

+0

@mmuzahid的末尾添加一個空白換行符。可惜的是,這並不起作用,即使我手動刪除「目標」目錄。 – dylhunn

回答

2

錯誤信息是混亂的,但問題是在testRegister方法。 render呼叫未正確關閉。

return ok(views.html.signuppage.render(Form.form(UserData.class)); 

應該

return ok(views.html.signuppage.render(Form.form(UserData.class))); 

錯誤消息可能是某種東西的Scala彈出。