저는 Spring을 처음 사용하며 다음을 원합니다.
1) 사용자가 localhost / admin / users를 방문 할 때 미리 정의 된 옵션을 적용하고 싶습니다.
2) localhost / admin / users 에는 POST
상사가 get을 사용하는 것을 원하지 않기 때문에 4 개의 매개 변수 를 사용하여 a를 수행하는 버튼이 있습니다 (그리고 사용하는 것이 더 낫다고 생각합니다 POST
)
3) 요청 adminUsersPost
을 관리 하는 컨트롤러 메서드 가 POST
있으며 해당 메서드가 메서드를 사용하여 브라우저를 다시로드하도록 할 수 adminUsersGet
있지만 POST
요청에 전송 된 정보를 사용하고 싶습니다 .
지금 내 브라우저에 표시되는 것은 이상한 인코딩으로 된 웹 페이지 콘텐츠가 포함 된 경고입니다. 정확하길 바라지 만 모르겠습니다.
@RequestMapping(value = "/admin/users", method = RequestMethod.GET)
public ModelAndView adminUsersGet(
Integer page,
Integer items,
String sorting,
String sortingDirection)
{
// predefined options
Integer pagina = 1;
Integer itemsPorPagina = 10;
String ordenacion = "idUsuario";
String dirOrdenacion = "asc";
// end of predefined options
// Code that I want for it to use POST params from the other method
ModelAndView mv = new ModelAndView("adminUsers");
return mv;
}
@RequestMapping(value = "/admin/users", method = RequestMethod.POST)
public ModelAndView adminUsersPost(
@RequestParam(value = "pagina") Integer pagina,
@RequestParam(value = "itemsPorPagina") Integer itemsPorPagina,
@RequestParam(value = "ordenacion") String ordenacion,
@RequestParam(value = "dirOrdenacion") String dirOrdenacion)
{
// Here I try to pass the POST parameters to the GET method for reloading
// the webpage with the new content
return adminUsersGet(pagina, itemsPorPagina, ordenacion, dirOrdenacion);
}
POST params-> GET same parameters 패턴은 일반적인 것입니다. 필요한 것은 매개 변수를 세션에 저장하고 GET 메서드로 리디렉션하는 RedirectAttributes입니다. GET이 히트되면 spring은 세션에서 모든 속성을 자동으로 제거하므로 GET 메소드의 브라우저 URL에 POST 매개 변수가 표시되지 않습니다. 여기 에서 완전한 예를 살펴보고 필요에 맞게 조정하십시오.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다