我在spring boot中有一个端点,它使用这个JSON作为例子:
{
"userId": 3,
"postBody": "This is the body of a post",
"postTitle": "This is the title of a post",
"created": null,
"tagList": ["tag1", "tag2", "tag3"]
}
Run Code Online (Sandbox Code Playgroud)
终点:
@RequestMapping(value="/newPost", method = RequestMethod.POST, produces="application/json", consumes = "application/json")
@ResponseBody
public ResponseEntity newPost(@RequestBody Map<String, Object> body) throws Exception {
Run Code Online (Sandbox Code Playgroud)
我知道这里的问题是Request body被保存为对象Map,除了tagList之外的所有其他属性都可以.如何让tagList成为Java中的字符串数组?
谢谢.
Ankur和Jose的答案混合在一起解决了这个问题,感谢快速响应的人!
我知道这个问题已经被问了很多,但我还没有找到解决该问题的任何答案。我本质上是在视图内部有一个表,该表使用PHP中的foreach循环显示,这将一张一张地吐出记录,并在最后一列(下载,删除和编辑)中附加一些“操作”按钮。下载和删除功能可以完美地工作,我只需将foreach循环中每个记录的ID传递进来,就可以完成工作。
我的模态有很多问题,当我在每个输入的“值”字段中回显数据时,它只会显示第一条记录中的数据。我真的很困惑如何使此功能正常工作(JQuery不是我最强的语言)。我已经看到了一些有关Ajax的反馈,但是我不希望在该项目中使用Ajax。我也在使用codeigniter框架以获取更多信息。
我认为问题在于,仅当foreach循环开始运行时才创建模态一次,因此为什么它只在模态中拥有第一条记录数据,因此需要任何帮助来解决此问题,以便我可以编辑表中的每条记录太好了!谢谢您的帮助。
HTML / PHP:
<div class="container" id="widecontainer">
<h1 id="title">VMS Failure Records</h1>
<br>
<!-- print table with results onto view.php -->
<table class="table table-bordered" id="record">
<?php if($results) : ?>
<thead>
<tr style="background-color: #d3d3d3;">
<th>ID</th>
<th>VSM S/N</th>
<th>VM S/N</th>
<th>Project</th>
<th>Site</th>
<th>Install Loc</th>
<th>Observed During</th>
<th>Comments</th>
<th>Reported By</th>
<th>Replaced With</th>
<th>Date</th>
<th>Failure Classification</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<!-- foreach result place it in row in table -->
<?php foreach($results as $res) : ?>
<tr>
<td><?php echo $res['id'] ?></td>
<td><?php echo …Run Code Online (Sandbox Code Playgroud)