第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

無法從 JS 獲取數(shù)組到我的 Spring 引導(dǎo)控制器?

無法從 JS 獲取數(shù)組到我的 Spring 引導(dǎo)控制器?

呼喚遠(yuǎn)方 2022-10-12 09:53:06
我在將數(shù)據(jù)從我的 React 應(yīng)用程序發(fā)送到我的 Spring Boot 控制器時(shí)遇到了一點(diǎn)問題,我通過 put 方法發(fā)送數(shù)據(jù),但是我得到 400,錯(cuò)誤,并且 eclipse 中彈出一個(gè)錯(cuò)誤,所以我所做的是:export const changeContratTypes = (idContrat, items, declaration) => {    const endpoint = template(CONTRAT_TYPES_CHANGE);    return instance // just an axios instance      .put(endpoint({ idContrat }), { items, declaration })      .then(values => values)      .catch(err => err.response);};我的端點(diǎn)常量是 url,很簡單,我發(fā)送聲明是一個(gè)整數(shù)和項(xiàng)目是一個(gè)對(duì)象數(shù)組,我的對(duì)象結(jié)構(gòu)是:{    id: 1, // or 2, 3, ....   isSelected: true, // or false   title: "a String here"       }為了在 Spring Boot 中得到這個(gè),我在我的控制器中創(chuàng)建了這個(gè)方法:@CrossOrigin(origins = "*")@ApiOperation(value = "${contrat.recuperation}", notes = "${contrat.recuperation.notes}", response = ContratDetailDto.class)@PutMapping(value="/{idContrat}/trtype")@ApiModelProperty(example = "4000004")@ApiResponses(value = {        @ApiResponse(code = 200, message = "Enrigistrer Les types de contrats ") })public ResponseEntity enrigistrerTypesDeContrat(@ApiParam(value = "${contrat.recuperation.param.id}") @PathVariable long idContrat, @RequestBody TypesConformites tcf) {    if (log.isDebugEnabled()) {        log.debug("appel de la méthode enrigistrerTypesDeContrat");    }    System.out.println("Voila "+tcf.getDeclaration());    return ResponseEntity.ok(HttpStatus.OK);}該控制器映射良好,其中的其他方法工作正常,但我使用的所有方法都是 Get 方法。我之前所做的是創(chuàng)建一個(gè)用作 RequestBody 的類:@Getter @Setterpublic class TypesConformites {   private int declaration;   private ArrayList<Item> items;    public TypesConformites() {   }} 這是我的項(xiàng)目類:@Getter @Setterpublic class Item {   private int id;   private String title;   private boolean isSelected;   public Item() {   }}
查看完整描述

1 回答

?
莫回?zé)o

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊


通常,該項(xiàng)目由杰克遜反序列化,如下所示:-


public void setId(String firstName) {


public void setTitle(String lastName) {


public void setSelected(boolean isActive) {

為避免這種情況,您可以更改項(xiàng)目和請(qǐng)求正文中的映射名稱.. 或用您的 isSelected 注釋@JsonProperty


查看完整回答
反對(duì) 回復(fù) 2022-10-12
  • 1 回答
  • 0 關(guān)注
  • 98 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)