小编Div*_*ver的帖子

什么是moxy相当于Jackson的JsonAnySetter?

我正试图转移到泽西岛2.0.这给了我杰克逊的痛苦,而且文档推荐使用Moxy.

我让Moxy为get和post调用工作,其中一切都匹配得很好但是我需要处理可能的未知元素.

// Handle unknown deserialization parameters
@JsonAnySetter
protected void handleUnknown(String key, Object value) {
    if (unknownParameters == null) {
        unknownParameters = new HashMap<>();
    }
    unknownParameters.put(key, value);
}
Run Code Online (Sandbox Code Playgroud)

这在换到球衣2.0之前运作良好,即使它在我离开它时不会引起任何问题也永远不会被调用.

我如何在Jersey 2.0中实现这一点?我对Moxy或Jackson很好.

我的依赖

'org.codehaus.jackson:jackson-mapper-asl:1.9.2',
'org.eclipse.persistence:org.eclipse.persistence.moxy:2.5.0',
'org.glassfish.jersey.media:jersey-media-moxy:2.0',
Run Code Online (Sandbox Code Playgroud)

这在我的web.xml中没有任何影响

<init-param>
    <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
    <param-value>true</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)

jackson moxy jersey-2.0

3
推荐指数
2
解决办法
2599
查看次数

如何设置使用ng-options创建的选择的初始值,其中Object为angularjs中的值

我有一个表单用于更新从restful服务填充的记录.

其中一个字段使用select作为查找值,我将它绑定到模型中的对象.

正确创建选择并选择选项可以对我的模型进行正确的更改.

问题是当我最初加载页面时,select是空白的.

有没有办法正确设置初始值,而不必抓取查找对象并匹配id以获取自动生成的索引位置?

或者更好的是,将值设置为对象而不是自动生成的索引.

<div ng-controller="MyCtrl">
    Id: <input ng-model="course.id" readonly><br>
    Cost: <input ng-model="course.cost" ng-required="true"><br>
    Title: <select ng-model="course.courseTitle" ng-options="title.name for title in courseTitles">
      </select> {{course.courseTitle.description}}<br>
    Length: <input ng-model="course.length" ng-required="true"><br>
    <br>
    Id: {{course.id}}<br>
    Cost: {{course.cost}}<br>
    Title: {{course.courseTitle.name}}<br>
    Length: {{course.length}}
</div>

function MyCtrl($scope) {
    $scope.course = {
        "id": "108",
        "cost": "155",
        "courseTitle": {
            "description": "Description of course 37.",
            "id": "37",
            "name": "Course 37 Name"
        },
        "length": "7"
    };

    $scope.courseTitles = [{
        "description": "Description of course 37.",
        "id": "37",
        "name": "Course 37 …
Run Code Online (Sandbox Code Playgroud)

angularjs

1
推荐指数
1
解决办法
5900
查看次数

标签 统计

angularjs ×1

jackson ×1

jersey-2.0 ×1

moxy ×1