-2

I am tried to implement search filter using Querydsl. my search filter functionality is working fine.But I tested this by giving hard coded values in controller.

Now I want to take that search parameter from Angular application. In get request how to receive this parameters from angularsClientAcctId, sAcctDesc,sInvestigatorName,sClientDeptId

Can any one please suggest me how to do that?

AccountController.java

@GetMapping("/findAccountData")
public ResponseEntity<List<Tuple>> populateGridViews(String sClientAcctId, String sAcctDesc,String sInvestigatorName,String sClientDeptId) throws Exception {                  

    return  ResponseEntity.ok(accService.populateGridViews(sClientAcctId, sAcctDesc,sInvestigatorName,sClientDeptId));

}

I tried like this using @PathVariable but here I need to pass all parameters then only request is matching other wise I am getting 404

My functionality is that If I didn't pass any parameters then I want all data, if I pass only one parameters then search according to that parameter value like that

 @GetMapping("/findAccountData/{clientAcctId}/{acctDesc}/{investigatorName}/{clientDeptId}")
    public ResponseEntity<List<Tuple>>  populateGridViews(
   @PathVariable("clientAcctId") String sClientAcctId,
   @PathVariable("acctDesc") String sAcctDesc,
   @PathVariable("investigatorName") String sInvestigatorName ,
   @PathVariable("clientDeptId") String sClientDeptId) throws Exception { 
John
  • 1,654
  • 1
  • 14
  • 21
SpringUser
  • 1,351
  • 4
  • 29
  • 59
  • 1
    Possible duplicate of [Spring MVC How take the parameter value of a GET HTTP Request in my controller method?](https://stackoverflow.com/questions/13442678/spring-mvc-how-take-the-parameter-value-of-a-get-http-request-in-my-controller-m) – jonrsharpe Jun 02 '18 at 08:00
  • But here I don't have view in my application. I want to receive it from angular application – SpringUser Jun 02 '18 at 09:32
  • That's irrelevant. The answer shows how to receive query parameters, it doesn't matter what client they come from. – jonrsharpe Jun 02 '18 at 09:37
  • means I can use `@RequestParam` to receive parameters from angular application which is not on my pc – SpringUser Jun 02 '18 at 10:04

1 Answers1

1

Use another type or parameter, @RequestParam

The controller would looks like this

@GetMapping("/findAccountData/")
public ResponseEntity<List<Tuple>>
populateGridViews(@RequestParam("clientAcctId") String
                          sClientAcctId, @RequestParam("acctDesc") String sAcctDesc, @RequestParam("investigatorName") String sInvestigatorName, @RequestParam("clientDeptId") String
                          sClientDeptId) throws Exception {
}

You can use /findAccountData/?clientAcctId=1&acctDesc=desc to pass wanted variables.

John
  • 1,654
  • 1
  • 14
  • 21
  • If my view is not present in my same application then also i can use `@RequestParam` – SpringUser Jun 02 '18 at 10:22
  • 1
    You are providing rest endpoints. Only if you are calling your controller method, or else all the request is coming from rest endpoint, no matter whether the caller is in the same application or not. – John Jun 02 '18 at 10:59