Jsp 在单独的输入中显示列表元素
我正在尝试在JSP中打印字符串列表。我的控制器中有:Jsp 在单独的输入中显示列表元素,jsp,spring-mvc,jstl,Jsp,Spring Mvc,Jstl,我正在尝试在JSP中打印字符串列表。我的控制器中有: List<String> profileNames = new Vector<String>(); ... modelMap.addAttribute("pn", profileNames); List profileNames=new Vector(); ... addAttribute(“pn”,profilename); 在我的JSP中: <c:forEach var="p" items="${pn}"
List<String> profileNames = new Vector<String>();
...
modelMap.addAttribute("pn", profileNames);
List profileNames=new Vector();
...
addAttribute(“pn”,profilename);
在我的JSP中:
<c:forEach var="p" items="${pn}" varStatus="rIndex">
<input type="text" value="${pn}"/>
</c:forEach>
通过这样做,每个输入框由列表中的所有元素填充
但是,我需要将列表中的每一项放在一个单独的输入框中,类似于
${pn.get(index)}
。我怎样才能做到这一点?您的方法很好,但输入值输入错误
替换此项:
<input type="text" value="${pn}" />
为此:
<input type="text" value="${p}" />