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

jsp显示不了Action穿过来的值

Action代码

public class ListNoticeAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private List<Notice> listNotice=new ArrayList<Notice>();

public List<Notice> getListNotice() {
return listNotice;
}

public void setListNotice(List<Notice> listNotice) {
this.listNotice = listNotice;
}

public String execute() throws Exception{
BeanFactory bf = WebApplicationContextUtils.getRequiredWebApplicationContext(ServletActionContext.getServletContext());
Dao dao = (Dao)bf.getBean("Daohibernate");
listNotice=dao.noticeList();
ActionContext.getContext().getSession().put("notice", listNotice);

System.out.println(listNotice.get(1).getNoticTilte());
return SUCCESS;
}
}

JSP代码
<table border="1" align="center" width="70%">
<tr>
<td>
序号
</td>

<td>
标题
</td>

<td>
时间
</td>

<td>
次数
</td>

<td>
操作
</td>
</tr>
<s:iterator value="notice">
<tr>
<td>
<s:property value="id"></s:property>
</td>

<td>
<s:property value="noticeTilte"></s:property>
</td>

<td>
<s:property value="date"></s:property>
</td>

<td>
<s:property value="readBy"></s:property>
</td>

<td>
<a href='./showUserRecord.action?user.id=<s:property value="id"></s:property>'>修改</a>
<a href='./deleteUser.action?user.id=<s:property value="id"></s:property>'
onclick="return del()">删除</a>
</td>
</tr>
</s:iterator>
</table>
求高手帮忙啊!!! Myeclipse中可以打印出值,但是JSP页面显示不出来,没有报错

------解决方案--------------------
试试看这行:
<s:iterator value="notice">
修改为:
<s:iterator value="#session.notice">


其实更建议楼主把 notice 写入 request.setAttribute 而不是 session 中。
------解决方案--------------------
我建议用<s:debug>查看下你把数据放到那个对象里面了,显示不出来数据,应该是取的值不对