JPBC ing: 留言板之三:留言板JSP代码

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<% @ page language = " java "  import = " java.util.*,DAO.impl.*,bean.* "
    pageEncoding
= " GBK "
%>
< jsp:useBean  id ="messageBoard"  scope ="page"
    class
="bean.MessageBoardBean"   />
<% ! int  totalPages;  // 页面总数

    
int  totalCount;  // 留言总数

    
int  currentPage;  // 当前页面

    
int  currentStart;  // 当前页面的第一条留言

    
int  countPerPage  =   5 // 设置页面可容纳的留言总数
%>
<%
    MessageDAOMySQL messageDAO 
=   new  MessageDAOMySQL();
    List messageList 
=  messageDAO.getMessageList();
    totalCount 
=  messageList.size();
    totalPages 
=  ( int ) Math.ceil(( double ) totalCount  /  countPerPage);

    
if  (request.getParameter( " page " ==   null ) {
        currentPage 
=   1 ;
    } 
else  {
        currentPage 
=   Integer .parseInt(request.getParameter( " page " ));
        
if  (currentPage  <   1 ) {
            currentPage 
=   1 ;
        } 
else   if  (currentPage  >  totalPages) {
            currentPage 
=  totalPages;
        }

    }

    currentStart 
=  totalCount  -  countPerPage  *  (currentPage  -   1 );
%>

< html >
    
< head >
        
< title > My JSP 'MessageBoard.jsp' starting page </ title >

        
< meta  http-equiv ="pragma"  content ="no-cache" >
        
< meta  http-equiv ="cache-control"  content ="no-cache" >
        
< meta  http-equiv ="expires"  content ="0" >
        
< meta  http-equiv ="keywords"  content ="keyword1,keyword2,keyword3" >
        
< meta  http-equiv ="description"  content ="This is my page" >
        
<!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    
-->

    
</ head >

    
< body >
        
< table  width ="100%"  border ="0"  cellspacing ="0"  cellpadding ="0" >
            
< tr >
                
< td  align ="center" >
                    
< table  border ="0"  width ="95%"  cellpadding ="0"  cellspacing ="0" >
                        
< tr >
                            
< td  height ="24" >
                                
< img  src ="cssjpgfiles/Com.gif"  border ='0' >
                                
< font  face ="宋体"  size ="3"  color ="#F9860A"
                                    style
="font-weight:bold" > BBS反馈 </ font >
                            
</ td >
                            
< td  align ="right" >
                            
</ td >
                        
</ tr >
                    
</ table >
                
</ td >
            
</ tr >
        
</ table >

        
<%
            
for  ( int  i  =   0 ; (i  <  countPerPage)  &&  ((currentStart  -   1   -  i)  >=   0 ); i ++ ) {
                messageBoard.setUserName(((MessageBoardBean) messageList
                .get(currentStart 
-   1   -  i)).getUserName());
                messageBoard.setTitle(((MessageBoardBean) messageList
                .get(currentStart 
-   1   -  i)).getTitle());
                messageBoard.setWords(((MessageBoardBean) messageList
                .get(currentStart 
-   1   -  i)).getWords());
                messageBoard.setTime(((MessageBoardBean) messageList
                .get(currentStart 
-   1   -  i)).getTime());
        
%>

        
< table  width ="98%"  border ="1"  cellspacing ="0"  cellpadding ="0"
            bordercolordark
="#FFFFFF"  bordercolorlight ="#CCCCCC" >
            
< tr >
                
< td  height ="22"  colspan ="2" >
                    
< table  width ="100%"  border ="0"  cellpadding ="0"  cellspacing ="0" >
                        
< tr >
                            
< td  height ="22" >
                                用户: 
<% = messageBoard.getUserName() %>
                            
</ td >
                            
< td  align ="right" >
                                
&nbsp;
                                
<% = messageBoard.getTime() %>
                            
</ td >
                        
</ tr >
                    
</ table >
                
</ td >
            
</ tr >
            
< tr >
                
< td  width ="109"  height ="100"  align ="center"  valign ="top" >
                    
< img  src ="cssjpgfiles/bs.GIF"  border ="0" >
                
</ td >
                
< td  width ="588"  valign ="top" >
                    
< table  width ="100%"  border ="0"  cellpadding ="0"  cellspacing ="0" >
                        
< tr >
                            
< td  height ="22"  bgcolor ="#EDEDED" >
                                
< font  color ="#FF0000" > 主题: <% = messageBoard.getTitle() %>   </ font >
                            
</ td >
                        
</ tr >
                        
< tr >
                            
< td  height ="5" ></ td >
                        
</ tr >
                        
< tr >
                            
< td
                                
style ="WORD-WRAP: break-word; line-height:15pt; font-size: 10pt;" >
                                
< font  color ="#0290C7" > <% = messageBoard.getWords() %>   </ font >
                            
</ td >
                        
</ tr >
                    
</ table >
                
</ td >
            
</ tr >
        
</ table >
        
<%
        }
        
%>

        
< table  width ="95%"  border ="0"  cellpadding ="0"  cellspacing ="0" >
            
< tr >
                
< td  height ="30" >
                    
< href ='MessageBoard.jsp?page=1'  clases =706501  title ='第一页' > [ < |]</a >
                    
< href ='MessageBoard.jsp?page=<%=  currentPage-1 % > ' title='前一页'>[ < ]</a >
                    
< font  color =#ff0000 > [ <% =  currentPage  %> ] </ font >
                    
<%
                        
for  ( int  i  =  currentPage  +   1 ; i  <=  totalPages; i ++ ) {
                     
%>
                    
< href ='MessageBoard.jsp?page=<%=  i % > '>[ <% =  i  %> ] </ a >
                    
<%
                        }
                     
%>
                    
< href ='MessageBoard.jsp?page=<%=  currentPage+1 % > ' title='后一页'>[>] </ a >
                    
< href ='MessageBoard.jsp?page=<%=  totalPages % > ' clases=706501 title='最后一页'>[>|] </ a >
                
</ td >
                
< td  align ="center" > 第  <% =  currentPage  %>  页,共  <% =  totalPages  %>  页,每页  <% =  countPerPage  %>  条,共有  <% =  totalCount  %>  条留言 </ td >
                
            
</ tr >
        
</ table >

    
</ body >
</ html >

posted on 2008-10-16 23:54 nonels 阅读(624) 评论(1)  编辑  收藏 所属分类: J2EE

评论

# re: JPBC ing: 留言板之三:留言板JSP代码 2016-04-22 09:09 545

210  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 
<2008年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿(2)

随笔分类(16)

随笔档案(16)

搜索

最新评论

阅读排行榜

评论排行榜