struts-10-主要标签
来源:互联网 发布:大数据的价值体现在 编辑:程序博客网 时间:2024/06/07 12:44
迭代标签
制造数据
package com.cx.ognl;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionSupport;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;/** * Created by cxspace on 16-7-14. */public class OnglDemo3 extends ActionSupport{ @Override public String execute() throws Exception { List<User> list = new ArrayList<User>(); Map<Integer,User> map = new HashMap<Integer , User>(); for (int i = 1 ; i< 11 ; i++){ User user = new User(i+"","CX"+i); list.add(user); map.put(Integer.parseInt(user.getId()),user); } //保存到request对象,取值要加# ActionContext.getContext().getContextMap().put("list",list); //放到root ActionContext.getContext().getValueStack().push(list); ActionContext.getContext().getValueStack().set("list",list); return super.execute(); }}
list迭代案例一
<%-- Created by IntelliJ IDEA. User: cxspace Date: 16-7-14 Time: 上午11:53 To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %><%@taglib prefix="s" uri="/struts-tags" %><html><head> <title>ognl</title></head><body> <s:iterator var="user" value="#request.list" status="st"> <s:property value="#user.id"></s:property> <s:property value="#user.name"></s:property> <s:property value="#st.even"></s:property> <br> </s:iterator></body></html>
list迭代案例二
<%-- Created by IntelliJ IDEA. User: cxspace Date: 16-7-14 Time: 上午11:53 To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %><%@taglib prefix="s" uri="/struts-tags" %><html><head> <title>ognl</title> <style type="text/css"> .odd{ background-color: blue; } .even{ background-color: crimson; } </style></head><body><br/>list迭代<br/><table border="1"> <tr> <td>用户id</td> <td>用户名</td> </tr> <!--迭代数据--> <s:iterator var="user" value="#request.list" status="st"> <!--是偶数,显示even样式,否则odd样式--> <tr class=<s:property value="#st.even?'even':'odd'"/> > <td><s:property value="#user.id"></s:property></td> <td><s:property value="#user.name"></s:property></td> </tr> </s:iterator></table></body></html>
map迭代
二.迭代map<br/><table border="1"> <tr> <td>用户id</td> <td>用户名</td> </tr> <!--迭代数据--> <s:iterator var="mp" value="#request.map" status="st"> <!--是偶数,显示even样式,否则odd样式--> <tr class=<s:property value="#st.even?'even':'odd'"/> > <td><s:property value="#mp.key"></s:property></td> <td><s:property value="#mp.value.name"></s:property></td> </tr> </s:iterator></table>
动态构建集合
<body> <br>一、动态构建list集合<br> <s:iterator var="str" value="{'a','b'}"> <s:property value="#str"></s:property> </s:iterator> <br>二、动态构建map集合<br> <s:iterator var="mpa" value="#{'cn':'China','usa':'America'}"> <s:property value="#mpa.key"></s:property> <s:property value="#mpa.value"></s:property> </s:iterator></body>
<s:form>标签
<s:form action="/user_login" method="post" name="frmlogin"> //服务器标签action不要写全路径 </s:form>
0 0
- struts-10-主要标签
- struts标签
- Struts标签
- Struts标签
- struts标签
- struts 标签
- Struts标签
- Struts标签
- struts标签
- Struts标签
- Struts标签
- struts标签
- struts标签
- struts标签
- Struts标签
- Struts标签
- Struts标签
- struts标签
- struts-基础内容-8-文件下载
- struts-核心内容-9-拦截器
- javaweb-c3p0连接池
- struts-核心内容-10-Ognl表达式语言
- Android系列之Service组件的应用
- struts-10-主要标签
- struts-11-表单数据校验
- struts标签解决用户输入验证的解决方案
- Hibernate学习-1-ORM 概念
- Hibernate学习-2-环境搭建
- Hibernate学习-3-API详解以及执行流程
- container_of分析
- 解构C#游戏框架uFrame兼谈游戏架构设计
- Hibernate学习-4-各种查询方式