我对百里香很陌生。我有一个包含多行的表,并尝试将ID发送到我的休息服务器。
<tr th:each="teilnahmeForm : ${teilnahmeFormList}">
<td th:utext="${teilnahmeForm.kongressBezeichung}"></td>
<td><a th:href="@{/user/editAbstract(teilnahmeId=${teilnahmeForm.id})}">Bearbeiten</a></td>
<!--<td><a th:href="@{/user/editFile(teilnahmeId=${teilnahmeForm.id})}">Bearbeiten</a></td>-->
<td>
<form method="POST" enctype="multipart/form-data" action="/user/uploadFile">
<table>
<tr>
<td><input type="file" name="file"/></td>
<td><input type="submit" value="Upload"/></td>
</tr>
</table>
</form>
</td>
</tr>
这是我的服务器:
@GetMapping("/user/uploadFile")
public ModelAndView handleFileUpload(@RequestParam("file") MultipartFile file
, int teilnahmeID
) {
ModelAndView modelAndView = new ModelAndView();
....
return modelAndView;}
我如何从选择要上传的文件的行中发送ID到我的rest-server-method?
答案 0 :(得分:0)
<tr th:each="teilnahmeForm : ${teilnahmeFormList}">
<td th:utext="${teilnahmeForm.kongressBezeichung}"></td>
<td><a th:href="@{/user/editAbstract(teilnahmeId=${teilnahmeForm.id})}">Bearbeiten</a></td>
<!--<td><a th:href="@{/user/editFile(teilnahmeId=${teilnahmeForm.id})}">Bearbeiten</a></td>-->
<td>
<form method="POST" enctype="multipart/form-data" action="/user/uploadFile">
<input type="hidden" name="teilnahmeID" th:value="${teilnahmeForm.id}" /> <!-- add this line -->
<table>
<tr>
<td><input type="file" name="file"/></td>
<td><input type="submit" value="Upload"/></td>
</tr>
</table>
</form>
</td>
</tr>