日期:2014-05-18  浏览次数:20654 次

请大家帮看下,谢谢了!
一段代码,请大家帮我看下,问题出在红色那行


<%
String url = "news%d";
for (int i = 0; i < 9; i++) {
url =String.format(url,i);
//url=url+i;
List list = (List) request.getSession().getAttribute(url);
if (list != null) {
News news = (News) list.get(list.size() - 1);
%>
<TR>
<TD class=news colSpan=2>
<A href="read.do?id=<%=news.getId()%>"><%=news.getArticleName() + url%></A> //这段代码的输出的url是9个news0,也就是传的i全是0,不知道为什么
</TD>
</TR>
<%
} else {
continue;
}
}
%>

------解决方案--------------------
引用楼主 Z8157522 的帖子:
一段代码,请大家帮我看下,问题出在红色那行 


<% 
String url = "news%d"; 
for (int i = 0; i < 9; i++) { 
url =String.format(url,i);
//url=url+i; 
List list = (List) request.getSession().getAttribute(url); 
if (list != null) { 
News news = (News) list.get(list.size() - 1); 
%> 
<TR> 
<TD class=news colSpan=2> 
<A href="read.do?id= <%=news.getId()%>"> <%=news.getArticleName() + url%…