我有课程
class a{
String name;
String lastname:
class[] b;
//getters and setters
}
class b{
String name;
String id:
//getters and setters
}
在servlet中我有一个gson字符串
class[] obj=gson.fromJson(gson string,a[].class);
request.setAttribute("object",obj);
和jsp
<c:forEach var="obj" items="${requestScope.object}">
<form action="servlet" method="POST">
<fieldset>
name: <c:out value="${obj.name}"></c:out>
last name:<c:out value="${obj.lastname}"></c:out>
<input type="submit value="submit" name="btn"/>
</fieldset>
</form>
<c:forEach items="${requestScope.object.b}" var="objb">
<c:set var="name" value="${obj.name}"></c:set>
<c:if test="${objb.name == name}">
<form action="servlet" method="POST">
<fieldset>
<input type="text" value="<c:out value="${objb.id}"></c:out>" name="id"/>
<input type="submit value="submit" name="btn2"/>
</fieldset>
</form>
</c:if>
</c:forEach>
</c:forEach>
有2个foreach和每个循环正在创建一个表单但是当我单击提交按钮时 我得到的值是null
的servlet
if(request.getParameter("btn2")){
System.out.println(request.getParameter("id"));//getting null value
}
我做错了吗?或表格被覆盖了?