模型类
public class SimpleResponse {
private String message;
private long id;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}
控制器类
@RestController
public class WebController {
// @RequestParam indicates that the endpoint /sample will have one Query
// parameter called name.
@RequestMapping("/sample")
public SimpleResponse sample(@RequestParam(value = "name", defaultValue = "Kabir") String name) {
SimpleResponse sm = new SimpleResponse();
sm.setId(1);
sm.setMessage("This message is for Kabir"+name);
return sm;
}
}
开发Spring Boot Rest Api时出现404错误。找不到错误。有人可以帮助我解决此问题吗?