//Input.jsp 跳转页面
<html>
<body>
<a href="test.action">String test</a>
</body>
</html>//Struts.xml
<struts>
<package name="test" extends="struts-default">
</action>
<action name="test" class="action.test">
<result name="success">tes.jsp</result>
</action>
</struts>
//action test
public class test extends ActionSupport{ private List<String> listTest;
private List<student> listBeanTest;
public List<String> getListTest() {
return listTest;
}
public List<student> getListBeanTest() {
return listBeanTest;
}
public void setListBeanTest(List<student> listBeanTest) {
this.listBeanTest = listBeanTest;
}
public void setListTest(List<String> listTest) {
this.listTest = listTest;
}
@Override
public String execute() throws Exception {
listTest =new ArrayList<String>();
listTest.add("hello1");
listTest.add("hello2");
listTest.add("hello3");
listBeanTest = new ArrayList<student>();
listBeanTest.add(new student("xiaohong","40","70."));
listBeanTest.add(new student("xiaozhang","40","70."));
listBeanTest.add(new student("xiaowang","40","70."));
return Action.SUCCESS;
}}
//tes.jsp
用<s:iterator/> <s:property/>怎么将Action 中的 listBeanTest 输出?
解决方案 »
- spring 定时任务中调用context 报异常NullPointer
- 问一下JAVA 类型的问题
- 有位Java架构师的文章不错
- java这样的查询语句能写吗?
- hibernate 多对多 一方需要更新
- 反射报道异常
- spring 事务处理的问题
- 在JSP页面使用Bean问题
- jbuilder9使用jakarta-struts-1.2.4出问题,是不是我配置出错了
- 请教一下为什么有时候用Object objRef = ic.lookup("java:comp/env/ejb/TheConverter");而有时候用ic.lookup("ejb")?
- myeclipse的问题
- 请问一个大型系统,项目该如何构建
<s:property/>
</s:iterator>
<s:property value="name"/>
<s:property value="age"/>
</s:iterator>
或者
<s:iterator value="listBeanTest" id="lst">
<s:property value="#lst.name"/>
<s:property value="#lst.age"/>
</s:iterator>
<s:property value="#lst[#status.index][0]"/>
<s:property value="#lst[#status.index][1]"/>
.................................
</s:iterator>
想怎么显示。简单说明一下.
比如 private map<map<student,student>,list<student>> complicateTest
setter...
getter...execute中
student t = new student();
map<student,student> mp = new HashMap<student,student>();
mp.put(t,t);
list<student> ls = new ArrayList<student>();
ls.add(student);
complicateTest = new map<map<student,student>,list<student>>();
complicateTest.put(mp,ls);
//如果我要显示complicateTest 怎么办
嵌套啊,有些东西自己可以摸索摸索呀。<s:iterator value="mapA">
<s:iterator value="获取mapA里的map">
</s:iterator>
</s:iterator>
%{} struts2里面取属性的两者皆可按对象的 点 方式取属性值