struts2中把查询出来的数据如何通过jsp显示

action的方法:
/**
*修改信息的方法使页面跳转到相应的页面
*/
public String modify(){
HttpServletRequest request=ServletActionContext.getRequest();
String positionId=request.getParameter("roleId");
//System.out.println("前台传过来的Id:"+positionId);
String hql="from Position p where p.positionId="+positionId;
List<Position> list=positionService.findEntitybyHQL(hql);
request.setAttribute("list",list);
return "modify";
}
jsp:页面
<s:iterator value="#request.list">
<tr height="28px">
<td class="TDBasLabel">职位编号:</td>
<td colspan="1">
<s:textfield name="positionNo" maxlength="16" cssStyle="width:100%;" cssClass="tdTextBox"/>
</td>
<td class="TDLabel">职位类型:</td>
<td colspan="1">
</td>
</tr>
<tr height="28px">
<td class="TDBasLabel">职位名称:</td>
<td colspan="3">
<s:textfield name="positionName" maxlength="30" cssStyle="width:100%;" cssClass="tdTextBox"/>
</td>
</tr>
</s:iterator>
==========================第二种情==================================
action 中方法:
/*
* 页面加载时就执行的方法
*/
@Override
public String execute() throws Exception {
System.out.println("进入这个方法");
HttpServletRequest request=ServletActionContext.getRequest();
List<Position> position = positionService.findEntitybyHQL();
request.setAttribute("position", position);
return SUCCESS;
}


jsp页面:
<s:iterator value="#request.position" status="st">
<tr style="background: <s:if test="#st.odd">#ccffff</s:if><s:else>#ccff99</s:else>" οnclick="enterEdit('<s:property value="positionId"/>')">
<td><div align="center"><input type="checkbox" name="checkItems" value="<s:property value="positionId"/>"/></div></td>
<td><div align="center"><s:property value="positionId"/> </div></td>
<td><div align="center"><s:property value="positionNo"/></div></td>
<td><div align="center"><s:property value="positionName"/></div></td>
<td><div align="center"><s:property value="jobClass"/></div></td>
<td><div align="center"><s:property value="workDesc"/></div></td>
<td><div align="center"><s:property value="workDemand"/></div></td>
<td><div align="center"><label οnclick="setRoleRights('<s:property value="positionId"/>')"> 权限</label></div></td>
<td><div align="center"></div></td>
</tr>
</s:iterator>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值