单击浏览器后退按钮后,它会发送一个发布请求,并且浏览器不允许它再次发送一个发布请求,并显示一个确认重新提交页面如何在 java 中使用 spring 框架避免此页面。
发布请求代码如下..
@RequestMapping(method = RequestMethod.POST, params = "action=search_by_name")
public ModelAndView searchByName(@RequestParam("contactName") String contactName, HttpSession session, WebRequest request) {
ModelAndView mav = new ModelAndView(determineSearchSummaryView(request));
ContactSearchHelper helper = new ContactSearchHelper(contactName);
// After all the selections they made lets filter out based on the limited Territories
CustomerUser user = (CustomerUser) userService.getLoggedInUser();
helper.preFilterTerritories(user.getTerritories());
EntitySearchCriteria criteria = helper.asCriteria(searchService);
addSummaryCounts(mav, criteria, searchService);
Long savedSearchId = searchService.save(criteria, SavedSearchType.CONTACT, false).getId();
helper.setSavedSearchId(savedSearchId);
session.setAttribute(getSearchHelperParam(), helper);
session.setAttribute("contactDiscovery", "false");
addAccordionData(mav, null);
addExtraModelData(mav);
return mav;
}