struts2传值jsp

1.action

package com.bc.web;

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

import org.apache.struts2.ServletActionContext;

import com.bc.bean.InformationParentSheet;
import com.bc.dao.impl.daoImpl;
import com.bc.service.impl.userServiceImpl;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class ListInfoAction extends ActionSupport {
	private userServiceImpl userService;
	private daoImpl dao;
	private List list;
	
	public daoImpl getDao() {
		return dao;
	}


	public void setDao(daoImpl dao) {
		this.dao = dao;
	}


	public userServiceImpl getUserService() {
		return userService;
	}


	public void setUserService(userServiceImpl userService) {
		this.userService = userService;
	}


	public List getList() {
		return list;
	}


	public void setList(List list) {
		this.list = list;
	}


	@SuppressWarnings("unchecked")
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		list=userService.pageInfo(1);
		return SUCCESS;
	}
}
 

2.struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
 
<struts>
	<constant name = "struts.custom.i18n.resources" value = "messageResoure_zh_CN"/>
	<constant name="struts.ui.theme" value="simple" />
	<constant name="struts.multipart.maxSize" value="41943040" />
	<constant name="struts.action.extension" value="action,do" />
	
	
	<package name="user" extends="struts-default" >
	 
		
		
		<action name="listInfo" class="ListInfoAction">
			<result>/NewsList.jsp</result>
		</action>
		
		
		
		
		
	</package>		
</struts>
 

3.jsp页面显示

 

<body leftmargin="0" rightmargin="0" topmargin="0"
		οnkeydοwn="if(event.keyCode==27) return false;">
		<div id="popLayer" style="position: absolute; z-index: 1000;"
			class="cPopText"></div>

		<form action="ProductDeleteMultiple.jsp" name="formDelete" method="post" target="detail">		
		<table class="tableborder" align="center" cellpadding="3"
			cellspacing="1" width="99%"  width="50%">
			<tbody>
				<tr class="header">
					<td align="center" width="7%">
						<a href="isRec.action">是否推荐</a>
					</td>
					<td align="center" width="7%">
						<a href="isHead.action">是否头条</a>
					</td>
					<td align="center" width="7%">
						所属类型
					</td>
					<td align="center" width="16%">
						新闻标题
					</td>
					<td align="center" width="14%">
						发布时间 
					</td>
					<td align="center" width="25%">
						新闻概要
					</td>
					<td align="center" width="5%">
						<a href="isPic.action">图片</a>
					</td>
					<td align="center" width="5%">
						备注 
					</td>
					<td align="center">
						操作
					</td>
				</tr>

				<s:iterator value="list" id="list">
				<tr>
					<td class="altbg2" align="center">
						<s:property value="ifRec"/>
					</td>
					<td class="altbg1" align="center">
						<s:property value="ifHeadline"/>
					</td>
					<td class="altbg1" align="center">
						<s:property value="informationParentSheet.ipName"/>
					</td>
					<td class="altbg1" align="center">
						<s:property value="ifTitle"/>
					</td>
					<td class="altbg1" align="center">
						<s:date name="ifPtTime" format="yyyy-MM-dd HH:mm"/>
					</td>
					<td class="altbg1" align="center">
						<s:property value="ifSummary"/>
					</td>
					<td class="altbg1" align="center">
						<s:if test=" #list.ifPicture != null">
					<img width="60px" height="60px" src ='${pageContext.request.contextPath}/UploadImages/<s:property value ="ifPicture"/>'/>
						</s:if>
					</td>
					<td class="altbg1" align="center">
						<s:property value="ifRemark"/>
					</td>
					<td class="altbg1" align="center">
						<s:a href="removeInfo.action?is.ifId=%{#list.ifId}" οnclick="return confirm('确定要删除该条新闻吗?')">删除</s:a>&nbsp;
						<s:a href="updatePInfo.action?is.ifId=%{#list.ifId}">修改</s:a>
						<s:a href="updateRecNews.action?type=isRec&&is.ifId=%{#list.ifId}&&ipId=%{#list.informationParentSheet.ipId}" οnclick="return confirm('确定设置为推荐新闻?')">设为推荐</s:a>&nbsp;
						<s:a href="updateHeadline.action?type=isHeadline&&is.ifId=%{#list.ifId}&&ipId=%{#list.informationParentSheet.ipId}&&thePicture=%{#list.ifPicture}" οnclick="return confirm('确定设置为头条新闻?')">设为头条</s:a>&nbsp;
					</td>
				</tr>
				</s:iterator>
				
			</tbody>
		</table><br/><br/>
		<center>
		
		<s:if test="list==null">
			查无数据!
		</s:if>
		
			
			<a href="listInfo.action">首页</a>
			&nbsp;
			<a href="splitPage.action?page=<s:property value="userService.pageNum-1"/>">上一页</a>
			&nbsp;
			<a href="splitPage.action?page=<s:property value="userService.pageNum+1"/>">下一页</a>
			&nbsp;
			<a href="splitPage.action?page=<s:property value="userService.pagecount"/>">尾页</a><br/><br/>
			第&nbsp;<s:property value="userService.pageNum"/>/<s:property value="userService.pagecount"/> 页
			&nbsp;
			&nbsp;共&nbsp;<s:property value="userService.count"/>&nbsp;条
	
	</center>
		<a name="bottom"></a>
	</body>
 

4.说明:

如以下,value="ifRec" 为list下的属性名.另在action内的属性只要提供了get方法,也可以直接在传递的jsp中取.

<s:property value="ifRec"/>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值