struts2的一点儿小问题

OGNL上下文中的根对象可以直接访问,不需要加任何特殊标记,而引用上下文中的其他对象需加“#”,ValueStack是上下文中的根对象 可以直接访问。
                           |
                            |--application
                            |
                            |--session
context map-----------------|--Value Stack(根)
                            |
                            |--request
                            |--parameters
                            |--attr(依次搜索page,request,session,application范围)




package com.jeedroid.news.action;

import java.util.List;
import java.util.Map;

import com.jeedroid.news.dao.NewsDealDao;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
/*jeedroid*/
public class SelectTitleAction extends ActionSupport
{
	private NewsDealDao newsDealDao;
	public void setNewsDealDao(NewsDealDao newsDealDao)
	{
		this.newsDealDao = newsDealDao;
	}
	@Override
	public String execute() throws Exception
	{//查出所有标题之后放到request请求中
		List newsTitleList = newsDealDao.selectNews();
		Map request = (Map)ActionContext.getContext().get("request");
		request.put("newsTitleList", newsTitleList);
		return SUCCESS;
	}

}



<body>
<s:iterator value="#request.newsTitleList"  id="tnew">
<s:property value="#tnew.title"/><br/>
</s:iterator>
</body>

iterator标签的id属性是迭代的List对象封装的单体。。。先记在这里。

你可能感兴趣的:(ValueStack)