---
title: "struts2的一点儿小问题"
author: "jeedroid"
date: "2012-02-13T18:33:12Z"
tags: ["valuestack"]
categories: ["企业架构"]
slug: "struts2"
draft: false
lastmod: "2012-02-13T18:34:39Z"
id: 1404782
url: "https://jeedroid.iteye.com/blog/1404782"
---

OGNL上下文中的根对象可以直接访问，不需要加任何特殊标记，而引用上下文中的其他对象需加“#”，ValueStack是上下文中的根对象 可以直接访问。 | |--application | |--session context map-----------------|--Value Stack（根） | |--request |--parameters |--attr(依次搜索page,request,session,application范围) \[code="java"]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; } }\[/code] \[code="java"]  
\[/code] iterator标签的id属性是迭代的List对象封装的单体。。。先记在这里。