- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道 stackoverflow 上有一些关于这个问题的问题。但我花了几个小时试图解决这个错误,但没有成功。
我使用 mysql 数据库来存储值。
我不断收到来自com.example.springboot.Recipe 文件。
这是 springboot 配方文件
package com.example.springboot;
import com.example.springboot.Recipe;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Entity // This tells Hibernate to make a table out of this class
public class Recipe {
public Recipe(){
}
public Recipe(Integer id, String name, String description, String type, Integer preptime, Integer cooktime, String content, Integer difficulty){
this.id = id;
this.name = name;
this.description = description;
this.type = type;
this.preptime = preptimee;
this.cooktime = cooktime;
this.content = content;
this.difficulty = difficulty;
}
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
private String name;
private String description;
private String type;
private Integer preptime;
private Integer cooktime;
@Column(columnDefinition = "TEXT")
private String content;
private Integer difficulty;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTitle() {
return name;
}
public void setTitle(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Integer getDifficulty() {
return difficulty;
}
public void setDifficulty(Integer difficulty) {
this.difficulty = difficulty;
}
public Integer getCookingtime() {
return cooktime;
}
public void setCookingtimeime(Integer cooktime) {
this.cooktime = cooktime;
}
public Integer getPreparationtime() {
return preptime;
}
public void setPreparationtime(Integer preptime) {
this.preptime = preptime;
}
}
Main Controller:
@PutMapping("/recipes/edit/{id}")
void updateRecipe2(@PathVariable int id, @RequestBody Recipe recipe ) {
Recipe recipe_ = recipeRepository.findById(id).get();
recipe_.setTitle(recipe.getTitle());
System.out.println("sss " + recipe.getname());
System.out.println("change");
recipeRepository.save(recipe_);
}
服务.ts:
updateRecipe2 (id: number, recipe: any): Observable<any > {
const url = `${this.usersUrl}/edit/${id}`;
return this.http.put(url ,recipe);
}
调用 updateRecipe2 的位置:
save(): void {
const id = +this.route.snapshot.paramMap.get('name');
this.recipeService.updateRecipe2(id, this.recipes)
.subscribe(() => this.gotoUserList());
}
一旦用户单击“保存”,此功能就会保存所做的更改。我希望我提供的代码片段足以帮助解决问题。预先感谢您。
我正在使用 Spring Boot 构建一个 REST API,并且使用 AngularJS 作为前端。我对网络开发还很陌生。
最佳答案
您正在向需要单个配方对象的 API 端点发送配方列表。
您的选择是:
一次仅发送一个配方对象,例如:
this.recipeService.updateRecipe2(id, this.recipes[0])
或者:创建一个新的 API 端点来接受配方列表,并“批量”编辑它们
@PutMapping("/recipes/edit")
void updateRecipes(@RequestBody List<Recipe> recipe ) {
关于java - JSON 解析错误 : Cannot deserialize instance of. 。超过 START_ARRAY token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60997963/
我的应用使用 Jackson。我得到的最小化构建主要使用此配置: # don't obfuscate Jackson classes -keep class com.fasterxml.** { *;
编辑:在我问这个问题的那一刻,我想到了尝试一些事情..我已经根据请求设置了 XmlNamespace 属性,这就成功了.. request.XmlNamespace = "http://musicbr
我使用可序列化和可反序列化的泛型。但是,Deserialize上有错误派生属性告诉无法推断类型。 struct 和 enum 都会抛出编译错误。评论其中之一不会解决任何问题。 use serde::{
passport.socketio 抛出此错误,同时无法授权用户。 Error: Error: Failed to deserialize user out of session 我已将问题范围缩小到
我正在尝试在具有借用内容的结构上派生反序列化: #[macro_use] extern crate serde_derive; use std::net::SocketAddr; #[derive(H
我执行查询以创建下面的Hive表: CREATE TABLE db1.test_create_tbl( column1 smallint COMMENT 'desc of column') COMME
这个问题在这里已经有了答案: Can System.Text.Json.JsonSerializer serialize collections on a read-only property? (
我正在使用 event_emmiter_rs用于我的应用程序中的事件处理。该库允许您订阅带有回调的事件并触发这些事件。事件采用 (strings, value) 的形式,回调采用接受值参数的闭包形式。
我收到一个错误...(不存在像默认构造函数这样的创建者):无法从对象值反序列化(没有基于委托(delegate)或基于属性的创建者),这表明我需要一个属性基于的创作者。我有几个具有不同参数但没有默认值
我相信我们需要一个自定义的反序列化器来对我们类的一个字段做一些特定的事情。看来一旦我这样做了,我现在负责反序列化所有其他领域。有没有办法让 jackson 反序列化除了我在这里关心的领域之外的所有领域
我有一个如下所示的类(class) class Person { Long id; String firstName; int age; } 我的输入看起来像这样: { "id
文档建议 NancyFx 帮助我解决 json 请求正文的 WRT 反序列化,但我不确定如何。请参阅下面的测试以演示: [TestFixture] public class ScratchNancy
考虑代码... using System; using System.Text.Json; public class Program { public static void Main()
有人让Deserializer工作吗?我正在方法“反序列化”而不是元素中获得完整的JSON表达式? public static void main(String[] args) { G
在尝试从 tokio TcpStream 反序列化为 JSON Value 时,我正在尝试使用此函数: use futures::prelude::*; use serde_json::Value;
我使用 Spring Boot 和 thymeleaf我尝试保存对象列表。 我的对象。 public class GECPD { public Integer id; public S
我正在尝试制作在线领唱。我需要从外部API获取包含货币值的表,正是从该页面:http://api.nbp.pl/api/exchangerates/tables/A?format=json我想在货币课
错误: java.lang.ClassNotFoundException: testprocedure.tp$3 at java.net.URLClassLoader$1.run(Unknown So
我开发了多个 GWT Web 应用程序。最新的一个是对另一个的稍微修改。除了最新的之外,所有这些都运行良好。异常(exception)是: The response could not be dese
我需要反序列化 1.5GB txt 文件。我正在使用 code.google.com/p/protobuf-net/中的 protobuf-net 有时它会因不同地方的不同异常(空引用、内存访问冲突)
我是一名优秀的程序员,十分优秀!