Linked Questions

Popular Questions

I was instructed to create webservices ( with Spring-Boot ). My colleague gave me the url of the webservice and it looks like this : http://172.20.40.4:8080/Oxalys_WS/stock/ITM=1559

In general we create a RestController with the url :

@RestController
@RequestMapping("stock")
public class StockController {

    @Autowired
    private StockService stockService;

    @GetMapping(value = "/{code}", produces = "application/json")
    public JsonModel getByCode(@PathVariable String code) {
        JsonModel jsonModel = new JsonModel();
        final Map<String, Object> data = new HashMap<>();
        List<Stock> stock = stockService.getByCode(code);
        data.put("stock", stock);
        data.put("stockTotal", stockService.getTotal(code));
        jsonModel.setDatas(data);

        return jsonModel;
    }
}

So is it normal to create a Restful Spring-Boot webservice with a parameter in the url ?

Related Questions