为方法signUp播放太多参数:()play.api.mvc.Call

时间:2017-03-11 13:09:27

标签: java playframework

signup.scala.html

Configuration Properties - C/C++  - Code Generation  

UserController.java

@(message: String)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<title>Register</title>
<script src="@routes.Assets.versioned("javascripts/practice.js")" 
type="text/javascript"></script>
</head>
<form method="post" onsubmit="return validateForm()" action="@routes.UserController.signUp()">
<table>
<tr>
    <td>
        First Name
    </td>
    <td>
        <input name="fName" type="text">
    </td>
</tr>
<tr>
    <td>
        Last Name
    </td>
    <td>
        <input name="lName" type="text">
    </td>
</tr>
<tr>
    <td>
        Username
    </td>
    <td>
        <input name="username" type="text">
    </td>
</tr>
<tr>
    <td>
        Address
    </td>
    <td>
        <input name="address" type="text">
    </td>
</tr>
<tr>
    <td>
        Email
    </td>
    <td>
        <input name="email" type="email">
    </td>
</tr>
<tr>
    <td>
        Password
    </td>
    <td>
        <input name="password" type="password">
    </td>
</tr>
<tr>
    <td>
        <input type="submit" value="Register">
    </td>
    <td>
        <input type="reset" value="Clear">
    </td>
</tr>
</table>
<p id="error" style="color: darkred"></p>
</form>
</html>

我有以下路线代码

public Result signUp() {
    //Gets from GET method
    String fName = form().bindFromRequest().get("fName");
    String lName = form().bindFromRequest().get("lName");
    String email = form().bindFromRequest().get("email");
    String password = form().bindFromRequest().get("password");
    String username = form().bindFromRequest().get("username");

    //Creating new instance
    User user = new User(username, fName, lName, email, password);
    User r = hash.put(username, user);
    //Adding user to array and check its added
    if (hash.put(username, user) != null) {
        return ok(login.render("Successfully Signup"));
    } else {
        return ok(("Sign up failed"));
    }
}

我的问题是,当我尝试访问http://localhost:9000/时,我得到:

POST     /signupUser                controllers.UserController.signUp

但是当我将signUp签名更改为UserController中的signUp(String id)时,它工作正常

0 个答案:

没有答案