Jsp页面无法显示List数值debug4天经历-dayTwo
来源:互联网 发布:dva防御矩阵启动英文 编辑:程序博客网 时间:2024/04/29 06:28
我觉得似乎table 内容似乎无法显示,修改代码如下:
<c:forEach begin="0" end = "1" var="i">
<tr>
<th>${i}</th>
<!-- <th>${Role.id}</th>
<th>${Role.accountId}</th>
<th>${Role.name}</th>
<th>${Role.level}</th>
<th>${Role.isOnline}</th>
-->
</tr>
</c:forEach>
页面可以显示table 的项目 。 i = 1, i =2 ,
重新改回来:
<c:forEach var="Role" items = "${RoleList}">
<tr>
<th>${i}</th>
<th><c:out value="${Role.name}" /></th>
<!-- <th>${Role.accountId}</th>
<th>${Role.name}</th>
<th>${Role.level}</th>
<th>${Role.isOnline}</th>
-->
</tr>
</c:forEach>
页面同样无法显示。 怀疑C标签的写法有问题 , 看struts 文档 , 改用 s标签 遍历iterator
<s:iterator value="#request.RoleList" var="strs">
<s:property value="#strs"/>
同样无法显示 , 改回C标签,发现自己的代码还有格式问题 将<th>改成<td>:
<c:forEach var="Role" items="${RoleList}">
<tr>
<td>fortest</td>
<td>${Role.accountId}</td>
<td>${Role.name}</td>
<td>${Role.level}</td>
<td>${Role.isOnline}</td>
</tr>
</c:forEach>
问题一直是table的内容无法显示! 包括 <td>fortest</td>这种直接显示的项目 。但是 明明 List 的size又大于 0 。
<%
List <Role> RoleList = new ArrayList<Role>();
RoleList = (List<Role>)request.getAttribute("RoleList");
if(RoleList!=null){
for(Role role:RoleList){
int id = role.getAccountId();
String name = role.getName();
System.out.println(name);
}
}
%>
写了java代码又来验证 1 : List 能否取到值 , 2 : 能否取到List 里面的值 。 输出证明可以取到 name 。
还是怀疑C标签可能取不到值 ,(我以前没用过C标签)
改为自己最熟悉的混合代码:
<% if(RoleList!=null){
int i = 0;
for(Role role:RoleList){
i++;
int id = role.getAccountId();
String name = role.getName();
System.out.println("wo are in circles,and the name is "+ name);
%>
<tr>
<td>${name}</td>
<td><%="name"%></td>
<td><%=name%></td>
<td><%=role.getName()%></td>
</tr>
<%
}
}
%>
结果控制台会输出 :wo are in circles,and the name is XXX .
显然,变量取到了值,但是却没有显示出来。我冤枉了 jstl core 标签 。 jstl 除了有core标签,还有另外3个标签库。
C 或者 S ,都是引用 的标记"prefix" 。我是绝对的jsp小白 一个。
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/struts-tags" prefix="s"%>
不过这天我确认了遍历 List的代码 写法没有问题 。 问题出在其他方面 。
下班回家。
- Jsp页面无法显示List数值debug4天经历-dayTwo
- Jsp页面无法显示List数值debug4天经历-dayOne
- Jsp页面无法显示List数值debug4天经历-dayThree
- Jsp页面无法显示List数值debug4天经历-dayFour
- 在JSP页面无法显示List集合.类似${list.size()},${user.getId()}的解决方法
- jsp页面中显示list的长度
- JSP页面显示list的常用方法
- jsp页面中数值不按科学计数法显示
- tomcat运行成功显示欢迎页面,jsp页面无法显示
- JSP/Servlet Web 学习笔记 DayTwo
- 经常换jsp页面导致页面无法显示
- 在jsp页面格式化数值
- 在JSP页面中显示List集合·
- 实现在JSP页面对LIST对象级联显示
- JSP页面中无法显示CSS中的背景图片
- servlet使用dispatcher转jsp页面,原本图片无法显示
- img标签在jsp页面无法显示时该怎么办
- 在服务器调试过程中,JSP页面无法正常显示
- 中国企业利用CES提升品牌知名度
- Android Fragment学习笔记(一)----Fragment的生命周期和派生类
- 李彬携洪剑涛跨界设计师 打造时髦孕妇装
- 程序员vs项目经理vs客户
- 警告:关于电磁辐射对孕妇的危害。
- Jsp页面无法显示List数值debug4天经历-dayTwo
- Installation error: INSTALL_FAILED_UID_CHANGED 的解决办法
- 很短,很文艺,很唯美的英语美句
- Silverlight使用微软自带的TOOLKIT创建右键菜单
- 2013新开始
- 创建Service程序并监控有界面的进程实现
- VC 多线程编程
- Android Fragment学习笔记(二)----Fragment界面添加和管理
- wget 技巧