java - Play Framework Error on BindRequest -
i'm getting following error on play 2.1.3: [runtimeexception: cannot instantiate class controllers.application$user. must have default constructor]
here's application.java file...i can't tell i'm doing wrong! occurs when make post request /login.
package controllers; import play.mvc.*; import play.data.*; import views.html.*; public class application extends controller { private static boolean loggedin = false; private static user currentuser; private static form<user> loginform = form.form(user.class); public static result index() { string message, title; if(!loggedin) { title = "login"; message = "please log in."; } else { title = "welcome"; message = "you logged in!"; } return ok(index.render(title, message, loggedin)); } public static result login() { currentuser = loginform.bindfromrequest().get(); if(currentuser.getusername().equals("test") && currentuser.getpassword().equals("password")) { loggedin = true; return redirect(routes.application.index()); } else { string title = "login"; string message = "an error occurred. please try logging in again."; return ok(index.render(title, message, loggedin)); } } static class user { private string username; private string password; public user() { this.username = ""; this.password = ""; } public string getusername() { return this.username; } public string getpassword() { return this.password; } } }
your user
class required have default constructor. providing constructor no formal paramaters, have overridden default constructor, therefore 1 not being generated @ compile time. try removing constructor , see if fixes problem.
Comments
Post a Comment