我使用Spring來創建和下載Excel表我想添加一些變量模型requestiong映射方法,這樣我可以在其他請求馬平方法如何在不使用會話的情況下在spring mvc中共享@RequestMapping方法中的模型對象?
@RequestMapping("/contentUploadDetails/{content_type}/{date}")
public ModelAndView contentUpload(
@PathVariable(value = "content_type") String content_type,
@PathVariable(value = "date") String date) {
List<CountAndValue> ls = contentCountImp
.getuploadedContentCountDatewise(content_type, date);
model.addObject("CountAndValue", ls);
return model;
}
使用正如你可以看到上面
model.addObject("CountAndValue", ls);
我想在我的其他requestMapping的方法來使用這個模型值
@RequestMapping(value = "/ContentUploadExport", method = RequestMethod.GET)
public ModelAndView getExcel() {
return new ModelAndView("CountAndValueExcel", "CountAndValue", CountAndValue);
}
我如何使用CountAndValueExcel模型對象在第二種方法中使用會話通過第一種方法設置?我可以將模型對象(包含類對象列表)從視圖發送回控制器嗎?
假設你從一個控制器重定向到另一個控制器,你可以使用flash屬性,checkout - http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-flash-屬性 –