我正在使用TroyGoode MVC PagedList https://github.com/TroyGoode/PagedList 工作得很好,除了我在第一页上有重复的内容
private void makeJsonObjectRequest() {
ac = new AppController();
final JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d("test", response.toString());
try {
// Parsing json object response
// response will be a json object
JSONArray name = response.getJSONArray("data");
for (int i = 0; i < name.length(); i++) {
JSONObject post = (JSONObject) name.getJSONObject(i);
try {
objectid = post.getString("object_id");
newRequest(objectid);
}
catch (Exception e) {
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("test", "Error: " + error.getMessage());
}
});
// Adding request to request queue
ac.getInstance().addToRequestQueue(jsonObjReq);
}
这给了我HTML输出:
@Html.PagedListPager((IPagedList)ViewData.Model.EnumerableAds, page => Url.Action("MyPage", "Home", new { page }))
我想重新说明:
<div class="pagination-container">
<ul class="pagination">
<li class="PagedList-skipToPrevious"><a href="/home/mypage?page=1" rel="prev">«</a></li>
<li><a href="/home/mypage?page=1">1</a></li>
<li class="active"><a>2</a></li>
<li><a href="/home/mypage?page=3">3</a></li>
<li class="PagedList-skipToNext"><a href="/home/mypage?page=3" rel="next">»</a></li>
</ul>
</div>
通过
<li class="PagedList-skipToPrevious"><a href="/home/mypage?page=1" rel="prev">«</a></li>
<li><a href="/home/mypage?page=1">1</a></li>
有可能吗?
答案 0 :(得分:0)
像@ Br4d建议的那样,这是完成此操作的代码
public ActionResult MyPage(int? page=1)
{
your code here
}
现在您可以为第一页发送空值,它将默认为第1页。