0

单击浏览器后退按钮后,它会发送一个发布请求,并且浏览器不允许它再次发送一个发布请求,并显示一个确认重新提交页面如何在 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;
}
4

1 回答 1

0

您只需要在发布到某个 URL 后使用重定向。您可以使用redirect:前缀或使用RedirectView.

于 2013-03-19T07:27:02.973 回答