這是我的代碼,我需要檢索POST發送數據:如何取回在java中發揮通後通過數據
@play.db.jpa.Transactional
public static Result registered(String fullname, String email, String password, String username) {
if(fullname.isEmpty()){
return badRequest("<p>fehlerhafte eingabe!</p>").as("text/html");
} else {
User user = new User();
user.fullname = fullname;
user.email = email;
user.password = password;
user.username = username;
user.save();
}
String success = "Successful registered!";
return ok(register.render(success));
}
,這是我的用戶等級:
public class User extends Model {
private static final long serialVersionUID = 1L;
public String fullname;
@Email
public String email;
@Required(message="Username erforderlich!")
public String username;
@Transient @Required
public String password;
public User(){}
public User(String username, String password, String fullname, String email) {
this.username = username;
this.password = password;
this.email = email;
this.fullname = fullname;
}
和這是我的html:
<form method="post" action="@routes.Application.registered()">
<p id="login_panel">@success</p>
fullname: <input type="text" name="fullname" id="fullname" value=""/>
email: <input type="text" name="email" id="email" value=""/>
username: <input type="text" name="username" id="username" value=""/>
password: <input type="password" name="password" id="password" value=""/>
<button type="submit">Register</button>
</form>
,這是在我的路線:
POST /registered controllers.Application.registered()
什麼是WSRequest?這可以成爲我的問題的線索嗎?
我很感激任何幫助!謝謝謝謝
是的,但問題是如何獲取通過郵件發送的數據。無論方法在哪裏,我都需要捕獲那些通過的值。 – doniyor
哦,現在我明白你的意思了。謝謝! – doniyor
抱歉轉儲的問題,但我必須這樣做所有的時間,爲什麼我不能只通過表單傳遞的數據沒有綁定到任何類字段? – doniyor