티스토리 뷰
Model
class Paging
{
private int currentPageNo;
private int totalPageNo;
private int startPageNo;
private int endPageNo;
public int CurrentPageNo { get { return this.currentPageNo; } }
public int TotalPageNo { get { return this.totalPageNo; } }
public int StartPageNo { get { return this.startPageNo; } }
public int EndPageNo { get { return this.endPageNo; } }
public Paging(int totalRowCount, int pageSize, int currentPageNo, int pagingSectionSize)
{
int totalPageNo = (int)Math.Ceiling((double)totalRowCount / pageSize);
int currentPagingSection = (int)Math.Ceiling((double)currentPageNo / pagingSectionSize);
int startPageNo = ((currentPagingSection - 1) * pagingSectionSize) + 1;
int endPageNo = (startPageNo + pagingSectionSize) - 1 <= totalPageNo ? (startPageNo + pagingSectionSize) - 1 : totalPageNo;
this.currentPageNo = currentPageNo;
this.totalPageNo = totalPageNo;
this.startPageNo = startPageNo;
this.endPageNo = endPageNo;
}
}
Controller
Paging paging = new Paging((int)param.TotalCount, facilitiesPageSize, currentPageNo, facilitiesPagingSectionSize);
ViewData["currentPageNo"] = paging.CurrentPageNo;
ViewData["totalPageNo"] = paging.TotalPageNo;
ViewData["startPageNo"] = paging.StartPageNo;
ViewData["endPageNo"] = paging.EndPageNo;
ViewData["totalCount"] = param.TotalCount;
return View();
View
<%
int startPageNo = (int)ViewData["startPageNo"];
int endPageNo = (int)ViewData["endPageNo"];
int currentPageNo = (int)ViewData["currentPageNo"];
int totalPageNo = (int)ViewData["totalPageNo"];
string preViewLink = currentPageNo > 1 ? Url.Action("RoomServiceList", new { currentPageNo = currentPageNo - 1 }) : "javascript:alert('이전 페이지가 존재하지않습니다.')";
string preView = string.Format("<a href={0}>이전</a>", preViewLink);
Response.Write(preView);
for (int i = startPageNo; i <= endPageNo; i++)
{
string pagingForm = string.Format("<a href={0} style='padding:0px 5px 0px 5px'>{1}</a>", Url.Action("RoomServiceList", new{ currentPageNo=i }), i);
Response.Write(pagingForm);
}
string nextViewLink = currentPageNo < totalPageNo ? Url.Action("RoomServiceList", new { currentPageNo = currentPageNo + 1 }) : "javascript:alert('다음 페이지가 존재하지않습니다.')";
string nextView = string.Format("<a href={0}>다음</a>", nextViewLink);
Response.Write(nextView);
%>
Query
/*
작성자 : 장정훈
설명 : 자유 게시판 목록
exec FreeBoard_List 1, 10, '', ''
*/
ALTER PROCEDURE dbo.FreeBoard_List
@currentPage int,
@pageSize int,
@searchType varchar(10),
@searchWord varchar(20),
@totalCount bigint output
AS
select @totalCount = count(*)
from FreeBoard with(nolock)
where 1=1 and
(
@searchType = 'subject' and @searchWord is not null and subject like '%'+@searchWord+'%'
or
@searchType = 'contents' and @searchWord is not null and contents like '%'+@searchWord+'%'
or
@searchType = 'subject' and @searchWord = '' and 1=1
or
@searchType = 'contents' and @searchWord = '' and 1=1
or
@searchType = '' and @searchWord = '' and 1=1
)
select *
from
(
select
row_number() over(order by seq asc) as No
, row_number() over(order by seq desc) as subSEQ
, seq
, subject
, contents
, writer
, regDate
from FreeBoard with(nolock)
where 1=1 and
(
@searchType = 'subject' and @searchWord is not null and subject like '%'+@searchWord+'%'
or
@searchType = 'contents' and @searchWord is not null and contents like '%'+@searchWord+'%'
or
@searchType = 'subject' and @searchWord = '' and 1=1
or
@searchType = 'contents' and @searchWord = '' and 1=1
or
@searchType = '' and @searchWord = '' and 1=1
)
) as tempTable
where tempTable.subSEQ between ((@currentPage -1) * @pageSize) + 1 and @currentPage * @pageSize
- Total
- Today
- Yesterday
- 문자 자르기
- nl2br
- 인텔리제이(intellij)
- java web-mvc
- docker
- 스프링 시큐리티(spring security)
- MainActor
- 람다식(lambda expression)
- System.Diagnostics
- java.sql
- java 키워드 정리
- 스프링 프레임워크(spring framewordk)
- React
- 스프링 시큐리티(spring security)-http basic 인증
- .submit()
- error-java
- jstl(java standard tag library)-core
- await
- 특정 문자를 기준으로 자르기
- 제품 등록
- 스프링 프레임워크(spring framework)
- jstl(java standard tag library)
- java-개발 환경 설정하기
- system.io
- jsp 오픈 소스
- REST API
- 표현 언어(expression language)
- 진수 변환
- 메이븐(maven)
- In App Purchase
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |