springboot怎么把数据传给前端:springboot 如何引入前端 bootstrap?
这种问题网上一搜一大堆,你可以具体找一篇文章试试,遇到问题可以针对相关问题去提问。springboot通过jar包方式引入bootstrap_个人文章 - SegmentFault 思否 这不是查查就
顺晟科技
2021-09-17 13:03:30
234
我从API中获取数据,并将其放入react中的表中,但当我试图从表中的一行编辑数据时。这给了我一个错误“PUT 400(错误请求)”。如何更改FormData()以接收来自“
---editar2.js---
handlerSubmit = async (event) => {
event.preventDefault();
let formData = new FormData();
formData.set("", event.target.legenda.value);
let resposta = await fetch("api/FotografiasAPI/" + this.props.idLinha, {
method: "PUT",
headers:{'Accept':'application/json','Content-Type':'application/json'},
body: formData
});
if (!resposta.ok) {
console.error("error:" + resposta.status);
}
return await resposta.json();
}
render(){
return(
<Modal
{...this.props}>
<Form onSubmit={this.handlerSubmit}>
<Form.Group controlId="legenda">
<Form.Label>legenda</Form.Label>
<Form.Control defaultValue = {this.props.legenda} type="text"name="legenda" required placeholder="legenda"/>
</Form.Group>
<Form.Group>
<Button variant="primary" type="submit">
Editar Restaurante
</Button>
</Form.Group>
</Form>
</Modal>
);}}
---后端---
[HttpPut("{id}")]
public async Task<IActionResult> PutFotografias(int id, [FromForm] Fotografias fotografias)
{
if (id != fotografias.ID)
{return BadRequest();}
_context.Entry(fotografias).State = EntityState.Modified;
try
{await _context.SaveChangesAsync();}
catch (DbUpdateConcurrencyException)
{
if (!FotografiasExists(id))
{return NotFound();}
else
{throw;}}
return NoContent();
}
顺晟科技:
05
2022-12
02
2022-12
02
2022-12
29
2022-11
29
2022-11
24
2022-11