2 moketudou moketudou 于 2014.04.29 10:23 提问

后台通过ServletRequestAware获得数据后,怎么在前端jsp显示

下面是action代码:

public class test2_action extends ActionSupport implements ServletRequestAware{
private test2_bill bill;
private String name;
private String pass;
public test2_bill getBill() {
return bill;
}
public void setBill(test2_bill bill) {
this.bill = bill;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}

public String login() {

ArrayList<test2> list = bill.list();
System.out.println("action++"+list.size());
req.setAttribute("clientslist", list);

// req.put("clientlist", list);
// ActionContext.getContext().getSession().put("clientslist", list);
return SUCCESS;
}
HttpServletRequest req;
@Override
public void setServletRequest(HttpServletRequest arg0) {
// TODO Auto-generated method stub
req=arg0;
}

}

我前端代码:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


<table border="1"  bgColor="#d0d0d0" cellspacing="1" cellpadding="1">
<tr>
<td>id</td><td>名称</td><td>密码</td>
</tr>
<script language="JavaScript">
alert();




/s:property

<td><s:property value="#item.name"></s:property> </td>
<td><s:property value="#item.pass"></s:property> </td>
<td>
</tr>
</s:iterator>

</table>
</div>


Csdn user default icon
上传中...
上传图片
插入图片