Je développe un projet utilisant Spring Boot. J’ai un contrôleur qui accepte les requêtes GET .
Actuellement, j’accepte les demandes adressées aux types d’URL suivants:
http: // localhost: 8888 / user / data / 002
mais je veux accepter les requêtes en utilisant les parameters de requête :
http: // localhost: 8888 / user? data = 002
Voici le code de mon contrôleur:
@RequestMapping(value="/data/{itemid}", method = RequestMethod.GET) public @ResponseBody item getitem(@PathVariable("itemid") Ssortingng itemid) { item i = itemDao.findOne(itemid); Ssortingng Itemname=i.getItemname(); Ssortingng price= i.getPrice(); return i; }
Utilisez @RequestParam
@RequestMapping(value="user", method = RequestMethod.GET) public @ResponseBody item getitem(@RequestParam("data") Ssortingng itemid){ item i = itemDao.findOne(itemid); Ssortingng Itemname=i.getItemname(); Ssortingng price= i.getPrice(); return i; }