not today
not today

Reputation: 37

Pass value with @Value to @RequestParam

So basically I have my rootFolderId in my application.properties

  app.property.rootFolder="some string "

and I need to get it in the Controller

 @Value("${app.property.rootFolder}")
    private static  String rootFolder ;

and use it in @RequestParam like :

@GetMapping({"/list"})
    public List<File> list(@RequestParam(defaultValue = rootFolder)  String parentId) 
{ ..../}

but I get the problem "Attribute value must be constant" .Is there any way to make it work ?

Upvotes: 1

Views: 509

Answers (1)

hsoj48
hsoj48

Reputation: 146

You can use property replacement in the @RequestParam field. See below.

@GetMapping({"/list"})
public List<File> list(@RequestParam(defaultValue = "${app.property.rootFolder}") String parentId) { ... }

Upvotes: 2

Related Questions