[二]SpringBoot 之 简单的接口

(1)编写一个实体类Demo

package me.shijunjie.entity;

public class Demo {
private long id; private String name; public long getId() {
return id;
} public void setId(long id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} }

(2)编写Controller

package me.shijunjie.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import me.shijunjie.entity.Demo; @RestController
@RequestMapping("/demo")
public class DemoController { @RequestMapping("/testDemo")
public Demo getDemo(){ Demo demo = new Demo(); demo.setId(1); demo.setName("Shijunjie"); return demo; }
}

(3)运行并测试

[二]SpringBoot 之 简单的接口

[二]SpringBoot 之 简单的接口

上一篇:一个简单的零配置命令行HTTP服务器


下一篇:Codeforces Beta Round #13 C. Sequence (DP)