responseentity object
@RequestMapping(value = "/getCountry2")
@ResponseBody
public Country getCountry2() {
var c = new Country();
c.setName("France");
c.setPopulation(66984000);
return c;
}
responseentity object
@RequestMapping(value = "/getCountry2")
@ResponseBody
public Country getCountry2() {
var c = new Country();
c.setName("France");
c.setPopulation(66984000);
return c;
}
responseentity object
package com.zetcode;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
responseentity object
package com.zetcode.controller;
import com.zetcode.bean.Country;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class MyController {
@RequestMapping(value = "/getCountry")
public ResponseEntity<Country> getCountry() {
var c = new Country();
c.setName("France");
c.setPopulation(66984000);
var headers = new HttpHeaders();
headers.add("Responded", "MyController");
return ResponseEntity.accepted().headers(headers).body(c);
}
@RequestMapping(value = "/getCountry2")
@ResponseBody
public Country getCountry2() {
var c = new Country();
c.setName("France");
c.setPopulation(66984000);
return c;
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us