0
私のデータベースからクエリを選択したいと思います。同じクエリ内に多くの検索項目があるので、リストから検索する必要があります。だから私はそれをするためのリストを取得したい。選択クエリはModel.addattribute
を追加するとうまく機能します。しかし、私はそれを望んでいません。私はAjaxからやりたいだから私はajaxのために書かれた別のコントロールにリストを渡したい。だから誰かが私にそれを手伝ってください。spring mvcのあるコントローラから別のコントローラへLISTを渡す方法
これは私のページ
@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
リストを渡したいですか?私はそれが私の検索リストを持っているので、私の以前のコントローラからunitList
を取得したい
List<SLSNotification> appbyUserID = jservice.getApplicationsByUnit(unitList);
このコードを追加するときに、残りのサービス(アヤックス)コントローラが
@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);
}
です。どうやってやるの?
... ingoredます。 –
いいえ、彼は必要なものすべてを返すように応答エンティティを返しています。 – Antoniossss
@Antoniossss .. How to this ...私はこれを行うことを理解しています –