struts2 Action向jsp传值问题,值总是取不出来,哪位大神知道是什么问题呢?万分感谢!
Action代码:privateList<Custome>custList=null;//有get,set方法publicStringsearchAction()thro...
Action代码:
private List<Custome> custList = null;//有get,set方法
public String searchAction() throws Exception {
CustDao custDao = new CustDao();
custList = custDao.custList();
System.out.print(custList.size()+"==="); //这里测试打印出来有值
request.setAttribute("custList", custList);
//ActionContext.getContext().put("custList", custList); //两种方法都试过
return "searchok";
}
jsp页面代码:
<s:iterator id="rv" value="#rqeuest.custList" status="st"> //此处也试过value="custList"
<tr>
<td>
<s:property value="cust_id"/> //此处也试过${rv.cust_id} ${cust_id}
</td>
<td>
<a href="#">删除</a> <a href="#">修改</a>
</td>
</tr>
</s:iterator>
struts.xml文件:
<package name="com.hshao.admin.action" extends="struts-default" namespace="/">
<action name="frame" class="com.hshao.admin.action.MainAction">
<result name="defaultpage" type="redirect">add.jsp</result>
<result name="searchok">search.jsp</result>
<result name="addok" type="redirect">add.jsp</result>
</action>
</package>
</struts>
结果就是怎么查询,在jsp页面都没有显示 展开
private List<Custome> custList = null;//有get,set方法
public String searchAction() throws Exception {
CustDao custDao = new CustDao();
custList = custDao.custList();
System.out.print(custList.size()+"==="); //这里测试打印出来有值
request.setAttribute("custList", custList);
//ActionContext.getContext().put("custList", custList); //两种方法都试过
return "searchok";
}
jsp页面代码:
<s:iterator id="rv" value="#rqeuest.custList" status="st"> //此处也试过value="custList"
<tr>
<td>
<s:property value="cust_id"/> //此处也试过${rv.cust_id} ${cust_id}
</td>
<td>
<a href="#">删除</a> <a href="#">修改</a>
</td>
</tr>
</s:iterator>
struts.xml文件:
<package name="com.hshao.admin.action" extends="struts-default" namespace="/">
<action name="frame" class="com.hshao.admin.action.MainAction">
<result name="defaultpage" type="redirect">add.jsp</result>
<result name="searchok">search.jsp</result>
<result name="addok" type="redirect">add.jsp</result>
</action>
</package>
</struts>
结果就是怎么查询,在jsp页面都没有显示 展开
1个回答
2017-12-11 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
<s:a action="role_delete?id=%{id}" onclick="return confirm('确定要删除吗?')">删除</s:a>
改成<s:a action="role_delete?id=${id}" onclick="return confirm('确定要删除吗?')">删除</s:a>
改成<s:a action="role_delete?id=${id}" onclick="return confirm('确定要删除吗?')">删除</s:a>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询