@GetMapping and @PostMapping instead of @RequestMappings change

This commit is contained in:
mokhan 2017-07-26 21:01:36 +05:30
parent 553c26c1a2
commit a3c47eca35

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");