如何获取更多详细信息:
我正在做Postman chrome扩展程序的简单休息请求。
我的控制器是:
@Controller
@RequestMapping("/theme")
public class ThemeController {
@RequestMapping(value = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
Status addTheme(@RequestBody Theme theme) {
try {
themeServices.addEntity(theme);
return new Status(1, "Theme added Successfully !");
} catch (Exception e) {
// e.printStackTrace();
return new Status(0, e.toString());
}
}
在Theme.java中:
@Entity
@Table(name = "theme", uniqueConstraints = { @UniqueConstraint(columnNames = { "theme_id" }) })
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
@NamedQuery(name = "Theme.findAll", query = "SELECT t FROM Theme t")
public class Theme implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "theme_id")
private long themeId;
private String description;
private String name;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "category_id", nullable=true)
private ThemeCategory themeCategory;
在ThemeCategory.java中:
@Entity
@Table(name = "theme_category", uniqueConstraints = { @UniqueConstraint(columnNames = { "category_id" }) })
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
@NamedQuery(name = "ThemeCategory.findAll", query = "SELECT t FROM ThemeCategory t")
public class ThemeCategory implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "category_id")
private long categoryId;
private String description;
private String name;
// bi-directional many-to-one association to Theme
// @OneToMany(mappedBy="themeCategory")
@OneToMany(mappedBy = "themeCategory", fetch = FetchType.EAGER)
@Column(nullable = true)
@JsonManagedReference
private Set<Theme> themes;
// bi-directional many-to-one association to ThemeCategory
@ManyToOne
@JoinColumn(name = "parent_category_id", nullable=true)
@JsonBackReference
private ThemeCategory parentThemeCategory;
// bi-directional many-to-one association to ThemeCategory
// @OneToMany(mappedBy="themeCategory")
@OneToMany(mappedBy = "parentThemeCategory", fetch = FetchType.EAGER)
@Column(nullable = true)
@JsonManagedReference
private Set<ThemeCategory> themeCategories;
主题类别表:
CREATE TABLE `theme_category` (
`category_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`parent_category_id` smallint(5) unsigned DEFAULT NULL,
`name` varchar(45) NOT NULL,
`description` varchar(1000) DEFAULT NULL ,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`category_id`),
KEY `idx_parent_category_id` (`parent_category_id`),
CONSTRAINT `fk_parent_category_id` FOREIGN KEY (`parent_category_id`) REFERENCES `theme_category` (`category_id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=301 DEFAULT CHARSET=utf8;
主题表:
CREATE TABLE `theme` (
`theme_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`category_id` smallint(5) unsigned NOT NULL,
`file_path` varchar(200) DEFAULT NULL,
`description` varchar(1000) DEFAULT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`theme_id`),
KEY `idx_category_id` (`category_id`),
CONSTRAINT `fk_category_id` FOREIGN KEY (`category_id`) REFERENCES `theme_category` (`category_id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=utf8;
我正在使用Postman扩展程序进行休息后呼叫:
http://localhost:8080/CustomerRegistration/theme/create
Header params:
Content-Type:application / json
Json Body:
{"description":"theme8","name":"theme8","themeCategory":{"categoryId":302, "themes":[],"parentThemeCategory":{}, "themeCategories":[]}}
用多种身体方式尝试了大约2个小时。但它一直在说:
服务器拒绝了此请求,因为请求实体的格式不受支持 按所请求方法的请求资源。
要分析,我没有得到任何其他东西。在Eclipse控制台中也没有显示有关此问题的任何内容。
有什么问题?是否有任何工具可以创建有效的请求。