我在Jsp页面中有两个ArrayList A和B,显示A的值,并检查B值是否相同
这是我的密码。 我有一个arrayList有保险清单,另一个arrayList为可以选择一个或多个保险的人。我想在复选框中显示所有保险,其中包含特定人员选择的保险的选中值。我在Jsp页面中有两个ArrayList A和B,显示A的值,并检查B值是否相同,jsp,servlets,Jsp,Servlets,这是我的密码。 我有一个arrayList有保险清单,另一个arrayList为可以选择一个或多个保险的人。我想在复选框中显示所有保险,其中包含特定人员选择的保险的选中值。 感谢您的帮助该复选框可以在属性checked=checked的情况下启用 如果将产品CSV转换为列表而不是数组,则可以使用其他方法,否则需要另一个嵌套循环来迭代pr 因此,您的JSP看起来像: <html> <head> <meta http-equiv="Content-Type" conte
感谢您的帮助该复选框可以在属性checked=checked的情况下启用 如果将产品CSV转换为列表而不是数组,则可以使用其他方法,否则需要另一个嵌套循环来迭代pr 因此,您的JSP看起来像:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Edit Plan</title>
</head>
<%! ArrayList<Edit_Pro> al;
ArrayList<String> st;
%>
<body>
<center>
<form action="Controller" method="get">
<input type="hidden" name="edit" value="true">
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Coverage</th>
<th>Status</th>
</tr>
<%
al=(ArrayList<Edit_Pro>)request.getAttribute("pro");
st=(ArrayList<String>)request.getAttribute("cov");
for(Edit_Pro ep:al){
%>
<tr>
<th><input type="text" value="<%="INC"+ep.getId()%>" name="id" disabled="disabled"></th>
<th><input type="text" value="<%=ep.getName()%>" name="uname" ></th>
<th>
<%
String pr[]=ep.getProduct().split(","); */ this bring a string. like :Accident,Dentist,beauty */
for(String s:st){
%>
// I am confused here.
<input type="checkbox" name="coverage" value="<%=s%>" > <%=s%><br>
<%} %>
</th>
<th><input type="text" name="status" value="<%=ep.getStatus() %>" disabled="disabled" ></th>
<th><input type="submit" value="Update">
</tr>
<%}%>
</table>
</form>
</center>
</body>
</html>
请将您的代码作为可编辑代码发布,而不是作为图像发布。还要指定您的结果,并给出预期结果的示例。完成。首先为没有这样做道歉。
<%
java.util.List<String> pr = java.util.Arrays.asList(ep.getProduct().split(","));
for(String s : st){
%><input type="checkbox" name="coverage" value="<%=s%>" <%
if(pr.contains(s)) {
%>checked="checked"<%
}
%>><%=s%><br/><%
<%} %>