简体   繁体   English

参数未知(播放!框架)

[英]Params unknown (Play! Framework)

It's a bit early on a Sunday morning for this (sorry) but here goes. 这个(抱歉)在星期天的早晨过早了,但是可以了。

The form I am working on is has a list of users (checkboxes) and some other fields below (dates, etc). 我正在使用的表单有一个用户列表(复选框)和下面的其他一些字段(日期等)。 The purpose of the form is to bulk add objects. 表单的目的是批量添加对象。 So, for each of these checkboxes (users) add an object with the user and the dates. 因此,对于每个这些复选框(用户),请添加一个带有用户和日期的对象。

The problem that I have is that I don't know how to capture the id's passed back through from params as I don't know the params names being passed through. 我遇到的问题是我不知道如何从参数中捕获返回的ID,因为我不知道要通过的参数名称。 Can you help? 你能帮我吗?

You can use u_index if you are in a list tag to have an index for your users 如果您在列表标记中,则可以使用u_index为用户提供索引

In you view 在您看来

#{list users, as:'u'}
  <input type="hidden" name="users[$[u_index -1].id" value="${u.id}">
#{/list}

and in your controller 并在您的控制器中

public static void save(List<User> users) {
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM