Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<script th:inline="javascript" defer>
function sampleSearch() {
if (notNullCheck($('#searchKeyword').val())) {
$('#pageIndex').val(1);
$('#listForm').attr('method', 'get').attr('action', contextPath + '/egovSampleList.do').submit();
} else {
alert(/*[[#{search.error}]]*/'검색어를 입력해주세요.');
Expand Down Expand Up @@ -45,7 +46,7 @@ <h2 class="heading-large" th:text="#{list.sample}"></h2>
<div id="content_pop">
<form id="listForm" th:object="${sampleVO}">
<input type="hidden" th:id="id" th:name="id" />
<input type="hidden" th:id="pageIndex" th:name="pageIndex" th:value="1" />
<input type="hidden" th:id="pageIndex" th:name="pageIndex" th:value="${sampleVO.pageIndex}" />

<!-- Search Form -->
<div class="form-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
*/
package egovframework.example.sample.web;

import static org.hamcrest.Matchers.containsString;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
Expand Down Expand Up @@ -72,7 +74,19 @@ class EgovSampleControllerTestSelectListTest {
}

@Test
void test_인덱스_리다이렉트() throws BaseRuntimeException, Exception {
void test_목록조회_현재페이지_히든필드_유지() throws Exception {
mockMvc.perform(
get("/egovSampleList.do")
.param("pageIndex", "2")
)
.andDo(print())
.andExpect(status().isOk())
.andExpect(view().name("sample/egovSampleList"))
.andExpect(content().string(containsString("name=\"pageIndex\" value=\"2\"")));
}

@Test
void test_인덱스_리다이렉트() throws Exception {
mockMvc.perform(get("/"))
.andDo(print())
.andExpect(status().isOk())
Expand Down