<c:forEach items="${files}" var="file"> <tr> <td>${file.name}</td> <td>${file.size}</td> <td> <a href="/cloud/download?path=${file.path}">下载</a> <button type="button" onclick="deleteFile('${file.path}')">删除</button> </td> </tr> </c:forEach>修改为jquery格式
时间: 2023-06-12 11:07:08 浏览: 45
$(function() {
$.each(${files}, function(index, file) {
var row = "<tr><td>" + file.name + "</td><td>" + file.size + "</td><td><a href='/cloud/download?path=" + file.path + "'>下载</a><button type='button' onclick='deleteFile('" + file.path + "')'>删除</button></td></tr>";
$("#fileTable").append(row);
});
});
其中 #fileTable 是你的文件列表所在的 table 的 id。
相关问题
<c:forEach items="${files}" var="file"> <tr> <td>${file.name}</td> <td>${file.size}</td> <td> <a href="/cloud/download?path=${file.path}">下载</a> <button type="button" onclick="deleteFile('${file.path}')">删除</button> </td> </tr> </c:forEach>修改为html格式
这段代码是使用了 JSP(JavaServer Pages)的标签库,将从后端传来的文件列表数据渲染成一个 HTML 的表格。若要将其转化为 HTML 格式,可以使用 HTML 标签来替代 JSP 标签,如下所示:
```
<table>
<thead>
<tr>
<th>Name</th>
<th>Size</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% for (var i = 0; i < files.length; i++) { %>
<tr>
<td><%= files[i].name %></td>
<td><%= files[i].size %></td>
<td>
<a href="/cloud/download?path=<%= files[i].path %>">Download</a>
<button type="button" onclick="deleteFile('<%= files[i].path %>')">Delete</button>
</td>
</tr>
<% } %>
</tbody>
</table>
```
在这个 HTML 代码中,我们使用了 for 循环来遍历文件列表,并使用 <%= ... %> 语法将变量渲染到 HTML 中。此外,我们也使用了 HTML 的 table、tr、th、td、thead、tbody 和 a、button 等标签来构建表格和按钮。
ssm用hadoop展示文件列表,上传文件,下载文件,删除文件前端代码
展示文件列表:
```
<c:forEach items="${files}" var="file">
<tr>
<td>${file.name}</td>
<td>${file.size}</td>
<td>${file.date}</td>
</tr>
</c:forEach>
```
上传文件:
```
<form action="/uploadFile" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="上传" />
</form>
```
下载文件:
```
<a href="/downloadFile?fileName=${file.name}">${file.name}</a>
```
删除文件:
```
<a href="/deleteFile?fileName=${file.name}">删除</a>
```