Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以HTML格式发送的信息_Html_Forms_Servlets_Html Table - Fatal编程技术网

以HTML格式发送的信息

以HTML格式发送的信息,html,forms,servlets,html-table,Html,Forms,Servlets,Html Table,我有一个HTML文件,向用户显示数据库的内容(它显示为一个表)。用户可以选择其中一行。完成后,用户所做的选择将发送到一个servlet,该servlet将处理该信息 假设这个servlet将查找与用户选择的信息相关的文件。我想做的是为用户提供一个选项,也可以选择servlet要查找的文件数量。这样,用户应该能够选择表中显示的一行,还应该能够键入要查找的文件数 到目前为止,我能够将用户在表中选择的内容发送到servlet,但我想知道是否可以将请求的文件数附加到该信息中 这是我的代码: <ce

我有一个HTML文件,向用户显示数据库的内容(它显示为一个表)。用户可以选择其中一行。完成后,用户所做的选择将发送到一个servlet,该servlet将处理该信息

假设这个servlet将查找与用户选择的信息相关的文件。我想做的是为用户提供一个选项,也可以选择servlet要查找的文件数量。这样,用户应该能够选择表中显示的一行,还应该能够键入要查找的文件数

到目前为止,我能够将用户在表中选择的内容发送到servlet,但我想知道是否可以将请求的文件数附加到该信息中

这是我的代码:

<center><form action="administ" method=post >                           
<center><table>
<table border=\"1\"><tr><th></th><th>Titleo</th><th>Author</th><th>Album</th></tr>
<c:forEach items="${items}" var="item">
<tr>                                
<td><input type="radio" name="Song" value="${item.file}@${item.title}#${item.author}$${item.album}">
<td>${item.title}</td>
<td>${item.author}</td>
<td>${item.album}</td>
</tr>
</c:forEach>
</table></center>
<tr><td colspan=2><input type=submit value = play name = option></td></tr>
<tr><td colspan=2><input type=submit value = Delete name = option></td></tr>

胸乳头
${item.title}
${item.author}
${item.album}

此时,我想添加一个新选项,它不仅需要一个新按钮,还需要用户引入一个数字。

这取决于具体情况。如果您想使用单选按钮选择一行,那么您可以在表的底部放置一个输入字段,在submit按钮的旁边。例如:

<input type="text" name="numberOfFiles">
但是,如果希望使用复选框选择多个行,或者希望此字段以任何方式显示在每行中,则需要为radio/checkbox字段指定行索引的值。如果您使用JSTL
对行进行迭代(我希望您确实这样做),那么您可以使用
varStatus
属性来声明一个。在循环内部,您可以通过获取行索引。例如:

通过复选框选择,您可以获得所有选定的行索引,从而也可以获得关联的输入字段,如下所示:

String numberOfFiles = request.getParameter("numberOfFiles");
String[] numbersOfFiles = request.getParameterValues("numberOfFiles");
String[] selectedIndexes = request.getParameterValues("selected");
for (String selectedIndex : selectedIndexes) {
    int index = Integer.parseInt(selectedIndex);
    String numberOfFiles = numbersOfFiles[index];
    // ...
}
或者,如果是单选按钮选中的行,则在任何情况下都是单选:

String selectedIndex = request.getParameter("selected");
int index = Integer.parseInt(selectedIndex);
String numberOfFiles = numbersOfFiles[index];

那要看情况。如果您想使用单选按钮选择一行,那么您可以在表的底部放置一个输入字段,在submit按钮的旁边。例如:

<input type="text" name="numberOfFiles">
但是,如果希望使用复选框选择多个行,或者希望此字段以任何方式显示在每行中,则需要为radio/checkbox字段指定行索引的值。如果您使用JSTL
对行进行迭代(我希望您确实这样做),那么您可以使用
varStatus
属性来声明一个。在循环内部,您可以通过获取行索引。例如:

通过复选框选择,您可以获得所有选定的行索引,从而也可以获得关联的输入字段,如下所示:

String numberOfFiles = request.getParameter("numberOfFiles");
String[] numbersOfFiles = request.getParameterValues("numberOfFiles");
String[] selectedIndexes = request.getParameterValues("selected");
for (String selectedIndex : selectedIndexes) {
    int index = Integer.parseInt(selectedIndex);
    String numberOfFiles = numbersOfFiles[index];
    // ...
}
或者,如果是单选按钮选中的行,则在任何情况下都是单选:

String selectedIndex = request.getParameter("selected");
int index = Integer.parseInt(selectedIndex);
String numberOfFiles = numbersOfFiles[index];

我在问题中添加了部分代码。当我显示表格时,我会向用户提供几个选项,例如播放音频文件,从数据库中删除它。。。现在我需要添加另一个选项,让用户选择其中一个文件(其中一行,我使用单选按钮),并引入一个数字。servlet需要数字和选定的行才能工作。我想我需要的是在表的末尾添加一个按钮,它也允许我引入一个数字。然后在表外的按钮旁边添加另一个输入字段?顺便说一下,
标记自1998年以来就被弃用了。使用CSS
margin:0自动。我正在将部分代码添加到问题中。当我显示表格时,我会向用户提供几个选项,例如播放音频文件,从数据库中删除它。。。现在我需要添加另一个选项,让用户选择其中一个文件(其中一行,我使用单选按钮),并引入一个数字。servlet需要数字和选定的行才能工作。我想我需要的是在表的末尾添加一个按钮,它也允许我引入一个数字。然后在表外的按钮旁边添加另一个输入字段?顺便说一下,
标记自1998年以来就被弃用了。使用CSS
margin:0自动