【问题标题】:consuming an array of objects in angularjs and json spring method post在 angularjs 和 json spring 方法 post 中使用对象数组
【发布时间】:2023-03-25 23:40:02
【问题描述】:

我想使用一个使用 angularjs 发布对象数组的 web 服务,该 web 服务工作正常,但是当我尝试使用 angularjs 使用它时出现错误:无法反序列化 java.util.ArrayList 的实例没有 START_OBJECT 令牌 我的 POJO 是这样的:

package org.test.metier;

import org.test.entities.T_Skill;

public class Skill_Level {

private T_Skill listSkills;
private int level;

// with getters and setters

这是我的方法

public T_LinkTalentSkill AddSkills(int lnId,List<Skill_Level> skill_Level) {
T_User u= t_UserRepository.findOne(lnId);
T_Talent t= u.getTalent();

    for(int i=0; i< skill_Level.size(); i++){
        T_LinkTalentSkill linkts =new T_LinkTalentSkill();
        linkts.setTalent(t);
        linkts.setSkill(skill_Level.get(i).getListSkills());
        linkts.setLnLevel(skill_Level.get(i).getLevel());
        linkRepository.save(linkts);
    }
    return null;
}

我的 angularjs 代码如下:

$rootScope.addSkills=function(){    

            $http.post('/AddSkills/' + $rootScope.lnId, $rootScope.skill_Level).success(function(data) {
                $rootScope.dataa= data;
                });
            };

最后是一些 HTML

<select ng-model="skill_Level[0].listSkills.lnId" class="form-control" id="s2example-1">
                        <option></option>
                            <option ng-repeat="t in listSkill" value="{{t.lnId}}">{{t.strLabel}}</option>
                    </select>
<select ng-model="skill_Level[0].level" class="form-control" id="sboxit-4">
                        <option>Select your country</option>
                        <option value="1">Level 1</option>
                        <option value="2">Level 2</option>
                        <option value="3">Level 3</option>
                        <option value="4">Level 4</option>
                    </select>

感谢任何帮助, 问候

【问题讨论】:

  • T_Skill 的邮政编码也是如此。
  • 我解决了我刚刚通过 Arraylist 切换 List 的问题,它的工作原理 :)
  • 您也可以回答自己的问题。 :)

标签: java angularjs json spring web-services


【解决方案1】:

我解决了我刚刚将 List 更改为 Arraylist 的问题,它工作正常

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-21
    • 2011-11-11
    • 1970-01-01
    • 1970-01-01
    • 2018-06-05
    • 2018-02-14
    • 1970-01-01
    相关资源
    最近更新 更多