Controller Terimleri
@ResponceBody = Bu anotasyon sayesinde spring mvc method return değerine httpmessageconverter'lar ile uygun formatta bir text mesaja cevirip istemciye döndürmektedir. Controller in üzerinde @Controller bulunmaktadır eğer istersek bunu koymak yerine @RestController ile değiştirip kullanmamıza gerek kalmayabilir @ResponceBody i.
@PathVariable =farklı id değerlerini içeren request URI ile erişildiğinde her birinde bu methodun çağrılması ve request URI dada Id le eşleşen bölümün methoda input arguman olarak geçilmesi sağlanmıştır. Örnek url:localhost:8080/owners/id buradaki çağırmak istediğimiz her id için bize yazdığımız metodu dönüyor ve eşliyor.
@RequestBody= method input argumanı olan Owner nesnesi RequestBody anotasyonuyla işaretlenmiş bu durumda web isteğinin içindeki body kısmı uygun httpmessageconvert vasıtası ile json veya xml olmasından owner nesnesine dönüştürülecek ve metoda input arguman olarak geçilecektir. Örnek Controller metodu: public ResponseEntity createOwner(@RequestBody Owner owner)
@RequestParam
Last updated
Was this helpful?