我在点击新闻标题时,要让他跳出新闻内容,但是总是跳出所有标题里的内容这是怎么回事? 不能一对一的对齐。
这是我要点击新闻标题的部分代码:
<logic:present name="newsList">
<logic:iterate id="mer" name="newsList" type="com.shop.orm.News">
<TR>
<TD class="text"> <img src="images/cateIcon.gif" border="0"> <a href="mer.do?method=searchNews&newsid=${mer.id}">${mer.title} </a> </TD>
</TR>
</logic:iterate>
</logic:present>
***************************
这是通过点击标题显示新闻内容的部分代码:
<TABLE width="96%" border=0 align="center" cellPadding=0 cellSpacing=0 class="C_Goods_Title">
<TR>
<TD> <div align="center" class="STYLE1">新闻阅览 </div> </TD>
</TR>
</TABLE>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#F7F3F7">
<logic:present name="newsList">
<logic:iterate id="mer" name="newsList" type="com.shop.orm.News">
<tr valign="middle" bgcolor="#FFFFFF">
<td class="text">${mer.content} </td> </tr>
<tr>
<td colspan="4" height="2" bgcolor="#F7F3F7"> </td>
</tr>
</logic:iterate>
</logic:present>
</table> </td>
</tr>
</table> </td>
*********************
这个是action里的代码:
public ActionForward searchNews(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// List merList = null;
// MerDAO service = new MerDAOImpl();
List newsList=null;
NewsDAO newsdao=new NewsDAOImpl();
try{
String hql = "from News as a ";
String hql1 = "select count(*) from News as a ";
String action ="mer.do?method=searchNews&"; String newsid = request.getParameter("newsid"); request.setAttribute("newsid", newsid);
hql = hql + "where a.content.id="+newsid; hql1 = hql1 + "where a.content.id="+newsid;
action = action + "newsid="+newsid+"&";
request.setAttribute("action", action);
newsList = newsdao.browseNewsTitle(); if (newsList!=null&&newsList.size()>0)request.setAttribute("newsList", newsList); }catch(Exception ex){
logger.info("在执行NewsAction类中的searchNews方法时出错:\n");
ex.printStackTrace();
}
return mapping.findForward("searchNews");
} 可能我这个action有错吧 ,但是我不知道应该怎么写??
数据库表News 字段id,title,content
高手帮帮忙 谢谢了 在线等
这是我要点击新闻标题的部分代码:
<logic:present name="newsList">
<logic:iterate id="mer" name="newsList" type="com.shop.orm.News">
<TR>
<TD class="text"> <img src="images/cateIcon.gif" border="0"> <a href="mer.do?method=searchNews&newsid=${mer.id}">${mer.title} </a> </TD>
</TR>
</logic:iterate>
</logic:present>
***************************
这是通过点击标题显示新闻内容的部分代码:
<TABLE width="96%" border=0 align="center" cellPadding=0 cellSpacing=0 class="C_Goods_Title">
<TR>
<TD> <div align="center" class="STYLE1">新闻阅览 </div> </TD>
</TR>
</TABLE>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#F7F3F7">
<logic:present name="newsList">
<logic:iterate id="mer" name="newsList" type="com.shop.orm.News">
<tr valign="middle" bgcolor="#FFFFFF">
<td class="text">${mer.content} </td> </tr>
<tr>
<td colspan="4" height="2" bgcolor="#F7F3F7"> </td>
</tr>
</logic:iterate>
</logic:present>
</table> </td>
</tr>
</table> </td>
*********************
这个是action里的代码:
public ActionForward searchNews(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// List merList = null;
// MerDAO service = new MerDAOImpl();
List newsList=null;
NewsDAO newsdao=new NewsDAOImpl();
try{
String hql = "from News as a ";
String hql1 = "select count(*) from News as a ";
String action ="mer.do?method=searchNews&"; String newsid = request.getParameter("newsid"); request.setAttribute("newsid", newsid);
hql = hql + "where a.content.id="+newsid; hql1 = hql1 + "where a.content.id="+newsid;
action = action + "newsid="+newsid+"&";
request.setAttribute("action", action);
newsList = newsdao.browseNewsTitle(); if (newsList!=null&&newsList.size()>0)request.setAttribute("newsList", newsList); }catch(Exception ex){
logger.info("在执行NewsAction类中的searchNews方法时出错:\n");
ex.printStackTrace();
}
return mapping.findForward("searchNews");
} 可能我这个action有错吧 ,但是我不知道应该怎么写??
数据库表News 字段id,title,content
高手帮帮忙 谢谢了 在线等
解决方案 »
- 求高人相助,struts2在使用iterator遍历对象集合,无法取值
- ps.setString(1, name); 放这段代码里什么意思
- 请教 Hibernate 中 querystring 写法? (在线等,谢谢)
- tomcat5.5中同时访问oracle和sql server有问题
- 有人知道吗?什么情况下for(int i=0;i<str.length-1;i++)里面的str.length-1是减1的。大部分小于str.length就可以了吗
- java web 套打如何实现
- 飞鱼编辑器的问题,请各位大侠帮帮忙!
- 把資料保存到數組的問題
- 请问为什么不能删除纪录
- 怎样使用javaBean调用javaBean
- 关于离开页面赋值session的问题,谢谢大家了
- 系统时间转换为时间格式为2009年9月26日
点击标题之后要通过标题id查询出这个标题对应的新闻内容,之后传回页面显示你现在的做法是把所有的新闻内容都返回给页面了正确做法是根据 newsid查询出News,把这个News对象传回给页面,不是存放所有News的list