2 lrlthink Lrlthink 于 2013.11.28 14:59 提问

springmvc的查询(包含分页)应该怎么做啊?

1、是通过ajax异步查询的方式还是直接页面刷新的方式呢?
2、mvc的封装模式下得到的数据应该怎么处理呢?

2个回答

qzshiyongjie123
qzshiyongjie123   2013.11.28 20:45
已采纳

可以用displaytag插件来做。
数据的处理,你全传给它,让它来处理。
举个例子。
配置struts2文件

 <package name="action" extends="struts-default">
        <action name="colums_*" class="coloumAction" method="{1}">
            <result name="borwColums">/page/{1}.jsp</result>
            <result name="input">/index.jsp</result>
        </action>
 </package>


public String browColums()
{
    columslist = ns.getScrollData(-1, -1).getResultlist();
    ServletActionContext.getRequest().setAttribute("columslist",columslist);

    for(NewColumns colums:columslist)
    {
        System.out.print(colums.getColumnCode());
    }

    return "borwColums";
}

borwColums.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <title>新闻标题展示</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <style type="text/css" media="all">
      @import url("${pageContext.request.contextPath }/css/maven-base.css"); @import url("${pageContext.request.contextPath }/css/maven-theme.css"); @import url("${pageContext.request.contextPath }/css/site.css"); @import
      url("${pageContext.request.contextPath }/css/screen.css");
    </style>
  </head>

  <body>
  <display:table name="columslist" id="row" pagesize="10" keepStatus="true" export="true">
    <display:column title="行号">${row_rowNum }</display:column>
    <display:column property="parent.columnName" title="父栏目名" />
    <display:column property="columnName" title="栏目名" />
    <display:column property="columnCode" title="栏目编号"/>

  </display:table>

  </body>
</html>
wabiaozia
wabiaozia   2016.02.18 17:03
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!