日期:2014-05-18  浏览次数:20772 次

struts实现显示数据?
显示从数据库里起出的数据?
大概说下就好(如有代码就更好了
谢谢

------解决方案--------------------
1、可以用struts的logic标签
<logic:notEmpty name= "allAttackSolution ">
<logic:iterate name= "allAttackSolution " id= "attackSolution " type= "struts.sample.cap1.sample3.entity.AttackSolution ">
<tr>
<td style= "word-break: break-all; " >
<bean:write property= "attack_event_code " name= "attackSolution "/>
</td>
<td style= "word-break: break-all; " >
<bean:write property= "attack_mean " name= "attackSolution "/>
</td>
<td style= "word-break: break-all; " >
<bean:write property= "attack_action " name= "attackSolution "/>
</td>
<td style= "word-break: break-all; " > <input type= "button " onclick= "del( ' <%=attackSolution.getAttack_event_code()%> '); " value= " <bean:message key= "message.delete "/> "> </td>
</tr>
</logic:iterate>
</logic:notEmpty>
-----------------------
2、可以用list()或者 Vector(我的的vector)

<%@ page contentType= "text/html;charset=GBK " language= "java " %>
<%@ page import = "StudyNews.* " %>
<%@ page import = "java.util.* " %>
<%
Vector v = (Vector)session.getAttribute(Constants.NEWS_LIST_KEY);
News news = null;
%>

<html>

<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 1 </title>

<table border= "0 " cellpadding= "0 " cellspacing= "0 " style= "border-collapse: collapse " bordercolor= "#111111 " width= "100% " id= "AutoNumber2 ">
<tr>
<td width= "13% ">   </td>
<td width= "87% ">
<img border= "0 " src= "images/mid-rdxw2.gif " width= "101 " height= "18 "> <p>

<%if(v != null ){

for(int i = 0;i < v.size();i++)
{
news = (News)v.get(i);
if (news.getType()==1){
%>


<span class= "s "> &nbsp; <a href= "newsDetail.do?newsId= <%=news.getId()%> "> <%=news.getTitle()%> </a> <br>

<%
}
}
%>


<p>
<img border= "0 " src= "images/mid-hyxw2.gif " width= "94 " height= "19 "> </p>

<% for(int i = 0;i < v.size();i++)
{
news = (News)v.get(i);
if (news.getType()==2){

%>

<p> <span class= "s "> &nbsp; <a href= "newsDetail.do?newsId= <%=news.getId()%> "> <%=news.getTitle()%> </a> <br>

<%
}
}
}
%>

<p>   </td>
</tr>
</table>


</html>
-----