当前位置: 代码迷 >> Java Web开发 >> struts兑现显示数据
  详细解决方案

struts兑现显示数据

热度:54   发布时间:2016-04-17 13:11:59.0
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>
--------------
java写入

public static Vector SearchNewsTitle(DB db) throws Exception{
  相关解决方案