<output> 不会在表单提交中发送。你应该添加 name 所有你的属性 <input> 您动态创建的元素。
<output>
name
<input>
input += "<input name='array' type='text' id='name" + i + "'" + " + ' /> " + "<input name='array' type='text' id='start" + i + "'" + " + ' /> " + "<input name='array' type='text' id='end" + i + "'" + " + ' /> <br/>";
然后,您可以在资源方法中执行此操作。
@Path("/applianceInfo") @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response applianceInfo(@FormParam("array") List<String> array)
记得 name 属性值 <input> element,这将是for参数的关键。所以请求体看起来像
array=hello&array=world&array=blah
这就是我们使用的原因 List 这里,因为密钥有多个参数 array 。
List
array
如果要将每一行组合在一起,可以考虑使用不同的格式(如JSON)来发送数据。