![](/img/trans.png)
[英]How to pass HashMap object from one method to another method in same Spring MVC controller class
[英]How to pass LIST from one controller to another controller in spring mvc
我想从数据库中选择查询。 我需要从列表中查找,因为它在同一查询中有很多搜索项。 因此,我想获得执行此操作的列表。 当我添加Model.addattribute
时,选择查询效果很好。 但是我不想要那个。 我想从Ajax做到这一点。 所以我想将列表传递给为ajax编写的另一个控件。 所以请有人帮我做到这一点。
这是我的控制器类,可获取我的页面
@RequestMapping(path = "/applicationManage")
public String viewApplicationPage(Model model) {
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
long userId = 0;
String agency = "";
String units = "";
List<String> unitsSLSI;
if (principal != null && principal instanceof AuthenticatedUser) {
AuthenticatedUser auth = (AuthenticatedUser) principal;
userId = auth.getUserId();
agency = auth.getAgency();
unitsSLSI = auth.getJobUnits();
}
return "applicationManage";
}
我想将unitsSLSI
列表传递给另一个控制器吗? 其余服务(ajax)控制器是
@RequestMapping(value = "/SLSIApp", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET)
@JsonIgnore
public ResponseEntity<List<SLSNotification>> listAllSLSI(List<String> unitList) {
List<SLSNotification> appbyUserID = jservice.getApplicationsByUnit(unitList);
if (appbyUserID.isEmpty()) {
return new ResponseEntity<List<SLSNotification>>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND
}
System.out.println("hibernate query " + new ResponseEntity<List<SLSNotification>>(appbyUserID, HttpStatus.OK));
return new ResponseEntity<List<SLSNotification>>(appbyUserID, HttpStatus.OK);
}
当我添加这根线
List<SLSNotification> appbyUserID = jservice.getApplicationsByUnit(unitList);
我想从以前的控制器中获取unitList
,因为它具有我的搜索列表。 我怎样才能做到这一点?
删除@JsonIgnore
,使您的响应变得充满生气...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.