java - 如何使用 Spring Boot 发送发布请求?
问题描述
我正在使用 POSTMAN 发送 post api 请求,它工作正常。我必须发送 JSON RAW
{
"id": "232",
"message": "elele",
"authorName": "JK Rowling"
}
我得到了成功的回应。但我想从用户界面发送发布请求,但它不起作用。
这是 ThymeLeaf 处理错误:
"Error during execution of processor 'org.thymeleaf.spring5.processor.SpringInputGeneralFieldTagProcessor'
这是它的html部分:
<form action="#" th:action="@{/api/v1/greetings}" th:object="${greeting}" method="post">
<p>Message: <input type="text" th:field="*{message}" /></p>
<p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p>
</form>
这是控制器代码:
@Controller
@RequestMapping(path = "/api/v1/greetings")
public class GreetingController {
@ApiOperation(value = "Create Greeting", notes = "Create a greeting based on the given input")
@PostMapping
public ResponseEntity<GreetingResponse> create(@Valid @RequestBody GreetingRequest greetingRequest) {
//
}
这是课程:
public class Greeting {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;
@Column(name = "message")
String message;
@Column(name = "author_name")
String authorName;
我哪里错了?
解决方案
推荐阅读
- reactjs - Nginx 在为多个 React 应用程序提供服务时冲突静态文件
- linux - 用 BashScript 制作酒店管理系统
- google-cloud-firestore - firestore python google cloud中的document.id(自动生成)是否有最大字符长度
- c++ - 如何在 C++ 中访问范围的变量输出?
- python - 使用基于 aiohttp 类的视图而不创建冗余端点
- amazon-web-services - 使用 Docker 提供 TensorFlow 服务
- excel - 将以下链接添加到形状后关闭 Excel 文件
- cypress - 赛普拉斯自定义命令不会返回值
- html - Angular - 根据 ngIf 结果更改组件样式
- python - /graphql 处的递归错误。超出最大递归深度