0
我在嘗試從控制器接收值時收到錯誤。在控制器中,我使用了兩個功能。這兩個函數返回一個值,查看頁面從控制器功能接收參數到查看頁面的問題
這裏是例子:
public static Result home() {
Identity user = (Identity) ctx().args.get(SecureSocial.USER_KEY);
String userEmail = user.email().isDefined() ? user.email().get() : "Not available";
System.out.println("Logged in - "+ userEmail);
String emailCheck = userEmail.substring(userEmail.indexOf("@") + 1, userEmail.length());
emailCheck = emailCheck.substring(0, emailCheck.indexOf("."));
if (emailCheck.matches(Messages.get("emailCheckAll"))) {
return ok(home.render(user));
}
public static Result getId() {
Map<String, String[]> parameters = request().body().asFormUrlEncoded();
String EAN_code= parameters.get("truckid")[0].trim();
List<Truck> isvalid= Truck.findTruckId(EAN_code);
System.out.println(EAN_code);
System.out.println(isvalid.get(0));
BigInteger qty=Truck.getTruckQuantity(EAN_code);
return ok(home.render(qty.toString()));
}
在home.scala.html我試圖收到這樣
@(user : securesocial.core.Identity)
(qty:String)
@import securesocial.core.IdentityProvider
@import Http.Context.Implicit
,但我不能獲得價值從數量。但我在控制器中有價值。相同的價值不去查看。請任何人幫助我。它顯示我的Scala文件「未找到值數量」的錯誤...
謝謝您的回覆花花公子。但我想從單獨的函數傳遞參數到單個頁面。這可能嗎?。如果一個特定的函數被調用,它應該採用該參數。你能幫我麼? – user3454863
我不明白你在問什麼,但是現在你已經定義了你的視圖來取兩個參數列表,並且只提供一個參數。 –
好吧夥計。我會解釋清楚。我想要從兩個不同的函數,即getId(),home()傳遞參數到單個視圖頁面,即home.scala.html。因爲我的應用程序應該在單個頁面中。所以我應該通過不同函數的變量來實現同一頁面的不同任務。在這種情況下,我必須做什麼來解決我的問題是否有任何方法可用?請回復 – user3454863