从动态jsp表获取值
我有一个从数据库动态生成值的表。列表变量是某个对象的arrayList从动态jsp表获取值,jsp,dynamic,html-table,Jsp,Dynamic,Html Table,我有一个从数据库动态生成值的表。列表变量是某个对象的arrayList <table border="1"> <tr> <th>Username</th> <th>Full Name</th> <th>Status</th
<table border="1">
<tr>
<th>Username</th>
<th>Full Name</th>
<th>Status</th>
<th>Action</th>
</tr>
<%for(int x = 0; x <list.size(); x++) {%>
<tr>
<td><% out.println(list.get(x).getUsername()); %></td>
<td><%out.println(list.get(x).getFirstname() + list.get(x).getMiddleinitial() + list.get(x).getLastname());%></td>
<td><% out.println(list.get(x).getStatus()); %></td>
<td>
<form action="ViewManager" method="POST">
<input id="button" type="submit" value="View" >
</form>
<form action="LockManager" method="POST">
<input id="button" type="submit" value="Lock" >
</form>
<form action="DeleteManager" method="POST">
<input id="button" type="submit" value="Delete" >
</form>
</td>
</tr>
<% }%>
</table>
用户名
全名
地位
行动
只需在隐藏输入元素的帮助下将其作为附加请求参数传递即可
例如
与具体问题无关,这是编写JSP的一种老派方法。上述方法对风险也很敏感。Java/JSP scriptlet没有内置的功能来防止这种情况。考虑使用<代码> <代码>遍历列表和<代码> fn:Exchange文件()/代码>以逃避用户控制的数据,以防止XSS攻击漏洞。
<c:forEach items="${users}" var="user">
...
<input type="hidden" name="username" value="${fn:escapeXml(user.username)}" />
...
</c:forEach>
...
...
另见:
谢谢!这真的很有帮助,所以如果我要实现它,它到底会是什么样子?不客气。只需单击链接,而不是像装饰一样忽略它们:)
String username = request.getParameter("username");
<c:forEach items="${users}" var="user">
...
<input type="hidden" name="username" value="${fn:escapeXml(user.username)}" />
...
</c:forEach>