2021-05-18

先创建包com.sdcet

RestaurantMain

@SpringBootApplication
public class RestaurantMain {
    public static void main(String[] args) {
        SpringApplication.run(RestaurantMain.class,args);
    }
}

 

在com.sedcet建包controller

HelloController

@Controller
@ResponseBody
public class HelloController {
    @RequestMapping("/hello")
    public String hello() {
        return "HELLO ??";
    }
        @RequestMapping("/getPhone")
                public Phone getPhone(){
            return new Phone();
            }

        @RequestMapping("/getSites")
            public Wrapper getSites(){
                Wrapper wrapper=new Wrapper();
                List<Website>websiteList=new ArrayList<>();
                Website websitel=new Website();
                websitel.setName("菜鸟驿站");
                websitel.setUrl("www.runoob.com");

                websiteList.add(websitel);

                Wrapper wrapper2=new Wrapper();

                Website websitel2=new Website();
                websitel2.setName("谷歌");
                websitel2.setUrl("www.google.com");
                websiteList.add(websitel2);


                Wrapper wrapper3=new Wrapper();

                Website websitel3=new Website();
                websitel3.setName("微博");
                websitel3.setUrl("www.weibo.com");
                websiteList.add(websitel3);
                wrapper.setSites(websiteList);
                return wrapper;
            }
        }

 

com.sdcet下建包entity

Phone

Website

Wrapper

public class Phone {
    private String brand;
    private String made;
public class Wrapper<Webstie> {
    private List<Webstie> sites;

    public void setSites(List<Webstie> sites) {
        this.sites = sites;
    }

    public List<Webstie> getSites() {
        return sites;
    }

}
    private double price=1000.88;
    private boolean newst=true;
    private String[] strArray={"Sunday","Monday","Tuesday"};

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getMade() {
        return made;
    }

    public void setMade(String made) {
        this.made = made;
    }
}
public class Website {
    private String name;
    private String url;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值