在Spring應用程序中,我需要保留用戶值直到我不刪除或銷燬。春季更改了會話值
根據它,我已經使用了的HttpSession在Controller如下
@Controller
public class MyController {
@RequestMapping(value = { "/search" }, method = RequestMethod.POST) //this hander called once
public String search(SearchVo aSearchVo, BindingResult result,
ModelMap model,HttpSession httpsession) {
if (result.hasErrors()) {
model.addAttribute("searches", new SearchVo());
return "home";
}
httpSession.setAttribute("searchstring", aSearchVo.getSearchString());
return "caseResult";
}
@SuppressWarnings("unchecked")
@RequestMapping(value = { "/filtersearch" }, method = RequestMethod.POST) //This handler call again and again
public String filterSearch(@ModelAttribute("filter") FilterVo fvo,ModelMap model , HttpSession httpSession){
String searchKeyWorld=httpSession.getAttribute("searchstring");
System.out.println(searchKeyWorld);
searchKeyWorld+=fvo.getFilterWorld();
return "caseResult";
}
}
但在會話變量,該值被作爲在最後一個過濾器自動地改變;因爲我沒有在filtersearch中設置任何會話變量Handler
我還沒有正確理解你的問題 –