set body from object ResponseEntity code example

Example 1: responseentity object



    4.0.0

    com.zetcode
    responseentityex
    1.0-SNAPSHOT
    jar

    
        UTF-8
        11
        11
    

    
        org.springframework.boot
        spring-boot-starter-parent
        2.1.0.RELEASE
    

    
        
            org.springframework.boot
            spring-boot-starter-web
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    
    

Example 2: responseentity object

@RequestMapping(value = "/getCountry2")
@ResponseBody
public Country getCountry2() {
    
    var c = new Country();
    c.setName("France");
    c.setPopulation(66984000);
    
    return c;
}

Tags:

Misc Example