我知道C程序通常以return结束,我们返回程序的状态.但是,我想返回一个字符串.原因是,我将从shell脚本调用C-executable并打印返回的字符串.有没有相同的机制?
我有一个简单的 springboot 程序,它接受一个 json 并打印它。主要目的是做 json 验证器包的使用,但当前的上下文是在基本的请求解析上。问题是当我尝试将输入请求映射到类实体时,它给出了以下错误:“org.springframework.http.converter.HttpMessageNotReadableException”,。
控制器(Hello.java):
@RequestMapping(method = RequestMethod.POST , consumes = "application/json")
public ResponseEntity<String> welcome(
@RequestBody DemoEntity demoEntity )
{
System.out.println(demoEntity.getName());
String response ="success";
return new ResponseEntity<>(response, HttpStatus.CREATED);
}
}
Run Code Online (Sandbox Code Playgroud)Java 类实体:
公共类 DemoEntity 实现了 Serializable {
@JsonProperty("name")
private String name;
@JsonProperty("no")
private int no;
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
} …Run Code Online (Sandbox Code Playgroud)