您需要通过将每个整数添加到POST或GET查询字符串来将它们传递给您的操作,如下所示:
myints=1&myints=4&myints=6
Run Code Online (Sandbox Code Playgroud)
然后在您的操作中,您将执行以下操作
public ActionResult Blah(List<int> myints)
Run Code Online (Sandbox Code Playgroud)
然后MVC将使用1,4和6填充列表
有一点需要注意.您的查询字符串中不能包含括号.有时,当javascript列表形成时,您的查询字符串将如下所示:
myints[]=1&myints[]=4&myints[]=6
Run Code Online (Sandbox Code Playgroud)
这将导致您的List为空(或计数为零).MVC无法正确绑定模型.
| 归档时间: |
|
| 查看次数: |
15869 次 |
| 最近记录: |