日期:2014-05-19  浏览次数:20692 次

请问我在StringBuffer里构建的HTML标签,我在for循环显示td里的值,第一行没问题,但第二行后,标签出问题了,这怎么回事。怎么解决。
package com.yidu.catersystem.socket;

import java.util.ArrayList;

import com.yidu.catersystem.entity.SysChangeDutyBean;
import com.yidu.catersystem.form.SysChangeDutyForm;

public class BrowsInterIml implements BrowsInter {

public String getMess(ArrayList<SysChangeDutyBean> list, String ip, int port) {
// TODO Auto-generated method stub
StringBuffer stringB=new StringBuffer();
String str = "http://"+ip+":"+port+"/caterSystem/sysChangeDuty.do?method=selectChange";
stringB.append("<html>");
stringB.append("<head>");
stringB.append("<body background=\"http://"+ip+":"+port+"/caterSystem/images/daronghebj.jpg \">");
stringB.append("<div style=\"height:870px; width:1400px; \">");
stringB.append("<div style=\"margin-top:200px; margin-left:80px; \">");
stringB.append("<form action=\"http://"+ip+":"+port+"/caterSystem/sysChangeDuty.do?method=selectChange\" method=\"post\">");
stringB.append("<table width=\"823\" height=\"76\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" bordercolor=\"#CCFF99\">");
stringB.append("<tr>"); 
stringB.append("<td width=\"168\" height=\"36\" style=\"font-size:30px; \"><div align=\"center\">餐桌号</div></td>");
stringB.append(" <td width=\"222\" style=\"font-size:30px;\"><div align=\"center\">菜品名称</div></td>");
stringB.append("<td width=\"113\" style=\"font-size:30px;\"><div align=\"center\">份量</div></td>");
stringB.append("<td width=\"188\" style=\"font-size:30px;\"><div align=\"center\">描述</div></td>");
stringB.append("<td width=\"100\" style=\"font-size:30px;\"><div align=\"center\">操作</div></td>");
stringB.append("</tr>");
for (int i=0;i<list.size();i++) {
stringB.append("<tr>");
stringB.append("<td>"+list.get(i).getChangeID()+"</td>");
stringB.append("<td>"+list.get(i).getHandller()+"</td>");
stringB.append ("<td>"+list.get(i).getAccepter()+"</td>");
stringB.append ("<td>"+list.get(i).getSuplus()+"</td>");
stringB.append("<td><a href="+str+">"+"成功"+"</a></td>");
stringB.append ("</tr>");

}
stringB.append("</table>");
stringB.append("</form>");
stringB.append("</div>");  
stringB.append("</div>");
stringB.append("</body>");
stringB.append("</html>");
return stringB.toString();
}

}


stringB.append("<td><a href="+str+">"+"成功"+"</a></td>");
就这里循环第二次的时候出问题了。求救!!



------解决方案--------------------
for (int i=0;i<list.size();i++) {
stringB.append("<tr>");
stringB.append("<td>"+list.get(i).getChangeID()+"</td>");
stringB.append("<td>"+list.g