MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » struts兑现显示数据

struts兑现显示数据

www.MyException.Cn  网友分享于:2013-12-02  浏览:17次
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{

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有