[英]How to pass LIST from one controller to another controller in spring mvc
I want to select query from my database. 我想从数据库中选择查询。 I need to find from a list because it has many search items in the same query. 我需要从列表中查找,因为它在同一查询中有很多搜索项。 So I want to get the list to do that. 因此,我想获得执行此操作的列表。 Select query works very well when I add Model.addattribute
. 当我添加Model.addattribute
时,选择查询效果很好。 But I don't want that. 但是我不想要那个。 I want to do it from Ajax. 我想从Ajax做到这一点。 So I want to pass the list to another control which is written for ajax. 所以我想将列表传递给为ajax编写的另一个控件。 So please someone help me to do that. 所以请有人帮我做到这一点。
This is my controller class which get my page 这是我的控制器类,可获取我的页面
@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";
}
I want to pass unitsSLSI
list to my another controller? 我想将unitsSLSI
列表传递给另一个控制器吗? The rest service (ajax) controller is 其余服务(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);
}
when I add this cord 当我添加这根线
List<SLSNotification> appbyUserID = jservice.getApplicationsByUnit(unitList);
I want to get unitList
from my previous controller because it has my search list. 我想从以前的控制器中获取unitList
,因为它具有我的搜索列表。 How can I do that? 我怎样才能做到这一点?
删除@JsonIgnore
,使您的响应变得充满生气...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.