日期:2014-05-17  浏览次数:20627 次

关于基于JSP的影院系统的问题
我在model层中定义了public ArrayList getRedSeat()函数,作用是返回已售出票的座位号和场次,放到了ArrayList中,然后我想在JSP中调用这个函数,然后使这个座位变成红色,表示已售出,那么问题就是,我该怎么把这些值传到JS中,使他改变座位(button)的颜色呢?JS怎么调用JSP中的JAVA代码的参数?
public ArrayList getRedSeat()
{
ArrayList al=new ArrayList();
try {
ct=new ConnDB().getCon();
sm=ct.createStatement();
rs=sm.executeQuery("select uid,bhang,blie from ubuy where bspend>0");

while(rs.next())
{
UbuyBean ub=new UbuyBean();
ub.setUid(rs.getInt(1));
ub.setBhang(rs.getInt(2));
ub.setBlie(rs.getInt(3));
//System.out.println("ub.getUid()="+ub.getUid());
al.add(ub);
}

} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}finally{
mbc.close();
}
return al;
}

------解决方案--------------------
action:
ActionContext.getContext().put("userTypeList",userTypeList);
上面相当于:request.setAttribute();
jsp接收:
List orgtypes = request.getAttribute("userTypeList");
orgtypes你把这个放到js里面循环判断下不就可以了么