为了账号安全,请及时绑定邮箱和手机立即绑定

这JSP脚本段怎么改为JSTL表达式,萌新死活改不了了!

这JSP脚本段怎么改为JSTL表达式,萌新死活改不了了!

慕斯卡6627364 2018-12-20 11:53:18
<%  List<StudentInfo> s = (List<StudentInfo>)session.getAttribute("studentList"); %><%   int i=0;   for(StudentInfo stu : s){  %>  <tr  <% if(i%2==0){%> bgcolor="#f0f8ff" <% } %>>     <td><%=stu.getId() %></td>   <td><$></td>   <td><%=stu.getName() %></td>   <td><%=stu.getOfClass() %></td>   <td><% if(stu.getSex()==1) out.print("男");else out.print("女"); %></td>   <td><%=stu.getBirthday() %></td>   <td><%=stu.getMajor() %></td>   <td><%=stu.getCourse() %></td>   <td><%=stu.getHobby() %></td>   <td><%=stu.getBeizhu() %></td>
查看完整描述

3 回答

?
欧阳熊猫

TA贡献6条经验 获得超2个赞

<%
  List<StudentInfo> s = (List<StudentInfo>)session.getAttribute("studentList");
 %>
 //如果使jsp脚本改为jstl,上面这段代码可以不必写,因为你在服务器端已经把对应的list放入
 //session域对象中了
 
 //再说下面的for循环   如何改为jstl    前提条件是需要导入jstl核心库  core
 //随后使用jstl标签即可
 
 <c:foreach item={你所要遍历的对象[从session域对象中获取]}  var="[遍历后把对象赋给谁]">
     //内部直接使用var变量.对应的属性即可  例如{n.id}
 </c:foreach>


查看完整回答
反对 回复 2018-12-26
  • 3 回答
  • 0 关注
  • 925 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信