年份分页查询

//Newpage新闻页面


 <s:iterator value="newlist">
<div id="title">
<a href="<%=path %>/New.jsp?id=${nid }&name=${name}">
<s:property  value="ntitle"/></a>
</div>
<div id="content">
<s:property value="nsumment" />
<p><s:property value="ndate" /></p>
</div>
</s:iterator>
<div class="fenye">
<c:if test="${ date==0 }">
         <ul>
            <li id="first"><a href="shownewNewAction.action?pageIndex=1"  >首页</a></li>
            <c:if test="${ pageIndex!=1 }">
            <li id="top" ><a href="shownewNewAction.action?pageIndex=${pageIndex-1 }"  >上一页</a></li>
            </c:if>
            <li class="xifenye" id="xifenye">
                <a id="xiye"><s:property value="pageIndex"/></a>/<a id="mo"><s:property value="total_news"/></a>
                <div class="xab" id="xab" style="display:none">
                </div>
            </li>
            <c:if test="${pageIndex!= total_news}">
            <li id="down" ><a href="shownewNewAction.action?pageIndex=${pageIndex+1 }" class="pg_next">下一页</a></li>
            </c:if>
            <li id="last"><a href="shownewNewAction.action?pageIndex=${ total_news }"  >末页</a></li>
      </ul>
</c:if>


<c:if test="${ date!=0 }">
         <ul>
            <li id="first"><a href="showdateNewAction.action?pageIndex=1"  >首页</a></li>
            <c:if test="${ pageIndex!=1 }">
            <li id="top" ><a href="showdateNewAction.action?pageIndex=${pageIndex-1 }"  >上一页</a></li>
            </c:if>
            <li class="xifenye" id="xifenye">
                <a id="xiye"><s:property value="pageIndex"/></a>/<a id="mo"><s:property value="total_news"/></a>
                <div class="xab" id="xab" style="display:none">
                </div>
            </li>
            <c:if test="${pageIndex!= total_news}">
            <li id="down" ><a href="showdateNewAction.action?pageIndex=${pageIndex+1 }" class="pg_next">下一页</a></li>
            </c:if>
            <li id="last"><a href="showdateNewAction.action?pageIndex=${ total_news }"  >末页</a></li>
      </ul>
</c:if>
 


//NewAction


package msit.action;


import java.sql.SQLException;
import java.util.List;


import msit.biz.CommentControl;
import msit.biz.NewControl;
import msit.entity.Comments;
import msit.entity.New;


public class NewAction {
    private  New news;
    private NewControl ne;
    private String tip;
    private List<New> newlist;
    private int id;
    private  Comments comm;
    private CommentControl cm;
    private List<Comments> commlist;
    public NewAction(){
        cm=new CommentControl();
        comm=new Comments();
        ne=new NewControl();
        news=new New();
    }
    private int pageIndex=1;
    private int pageSize=5;
    private int total_news;
    private int total;
    public int getPageIndex() {
        return pageIndex;
    }
    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }
    public int getPageSize() {
        return pageSize;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    public int getTotal_news() {
        return total_news;
    }
    public void setTotal_news(int total_news) {
        this.total_news = total_news;
    }
    public int getTotal() {
        return total;
    }
    public void setTotal(int total) {
        this.total = total;
    }
    private static int date;
    
    public int getDate() {
        return date;
    }
    public void setDate(int date) {
        this.date = date;
    }
    public Comments getComm() {
        return comm;
    }
    public void setComm(Comments comm) {
        this.comm = comm;
    }
    public List<Comments> getCommlist() {
        return commlist;
    }
    public void setCommlist(List<Comments> commlist) {
        this.commlist = commlist;
    }
    public void setCm(CommentControl cm) {
        this.cm = cm;
    }
    public NewControl getNe() {
        return ne;
    }
    public void setNe(NewControl ne) {
        this.ne = ne;
    }
    
    public New getNews() {
        return news;
    }
    public void setNews(New news) {
        this.news = news;
    }
    public NewControl getCm() {
        return ne;
    }
    public void setCm(NewControl cm) {
        this.ne = cm;
    }
    public String getTip() {
        return tip;
    }
    public void setTip(String tip) {
        this.tip = tip;
    }
    public List<New> getNewlist() {
        return newlist;
    }
    public void setNewlist(List<New> newlist) {
        this.newlist = newlist;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    
    /**
     * 查询用户集合
     * @return 结果字符串
     */
    public String showlist(){
        select();
        //news = ne.getNewsByid(id);
        if (null!=news ) {
            return "showlist";
        }else {
            return "error";
        }
    }
    /**
     * 查询用户集合
     * @return 结果字符串
     */
    public String shownew(){
            selectnew();
            newlist = ne.getPageList(pageSize,pageIndex);
            if (null!=newlist && newlist.size()>=1) {
                return "shownew";
            }else {
                return "error";
            }
    }
    public String showdate(){
            selectdate();
            newlist = ne.getDate(date,pageSize,pageIndex);
            if (null != newlist && newlist.size() >= 1) {
                return "shownew";
            }else {
                return "error";
            }
    }
    
    /**
     * 查询新闻总共的页码
     * @return
     */
    public String selectnew(){
        if (ne.getNewsCount()%5==0) {
            total_news=ne.getNewsCount()/pageSize;
        } else {
            total_news=ne.getNewsCount()/pageSize+1;
        }
            return "total_news";
    }
    public String selectdate(){
        if (ne.getdateCount(date)%5==0) {
            total_news=ne.getdateCount(date)/pageSize;
        } else {
            total_news=ne.getdateCount(date)/pageSize+1;
        }
            return "total_news";
    } 
}


//Struts


 <action name="*NewAction"   class="msit.action.NewAction" method="{1}">
           <result name="success" type="redirect">/index.jsp</result>
     <result name="error" type="redirect">/error.jsp</result>
     <result name="showlist" >/New.jsp</result>
     <result name="show" >/New.jsp</result>
     <result name="newlist" >/Newpage.jsp</result>
     <result name="shownew" >/Newpage.jsp</result>
     <result name="list"  type="redirectAction">showlistNewAction</result>
   </action>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值