Merge pull request #2317 from half-wit4u/master

@GetMapping and @PostMapping instead of @RequestMappings change
This commit is contained in:
slavisa-baeldung 2017-07-28 12:56:01 +02:00 committed by GitHub
commit 17d7f8fe59

View File

@ -6,9 +6,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.baeldung.web.log.data.RateCard; import com.baeldung.web.log.data.RateCard;
@ -23,14 +23,14 @@ public class TaxiFareController {
private static final Logger LOGGER = LoggerFactory.getLogger(TaxiFareController.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaxiFareController.class);
@RequestMapping(method = RequestMethod.GET, value = "/taxifare/get/") @GetMapping(value = "/taxifare/get/")
@ResponseBody @ResponseBody
public RateCard getTaxiFare() { public RateCard getTaxiFare() {
LOGGER.debug("getTaxiFare() - START"); LOGGER.debug("getTaxiFare() - START");
return new RateCard(); return new RateCard();
} }
@RequestMapping(method = RequestMethod.POST, value = "/taxifare/calculate/") @PostMapping(value = "/taxifare/calculate/")
@ResponseBody @ResponseBody
public String calculateTaxiFare(@RequestBody @Valid TaxiRide taxiRide) { public String calculateTaxiFare(@RequestBody @Valid TaxiRide taxiRide) {
LOGGER.debug("calculateTaxiFare() - START"); LOGGER.debug("calculateTaxiFare() - START");