1

我的目标是将值显示为从表格到 JSP 页面上模型弹出窗口的列表。

行动

public class IcdAction extends ActionSupport {

    private List<Icd10> icdCodes;

    public String execute() throws MalformedURLException, JsonProcessingException {
        SomeProcess ap = new SomeProcess();
        icdCodes = ap.getList();
        return SUCCESS;     
    }
}

js

var myApp = angular.module('myApp', []);

myApp.controller('MainCtrl', function ($scope, $http) {

    $http.get('IcdCodesAction')
    .success(function(response){
         $scope.icdcodes = response;
    });
});

struts.xml

<action name="IcdCodesAction" class="com.emr.action.IcdAction" >    
    <result type="json">
    </result>
</action>

在我使用的 JSP 文件ng-repeaticdcodes

我是 AngularJS 的新手。我无法弄清楚阻止显示列表的问题出在哪里。

如果我使用硬编码的 json 数据$scopes.icdcodes,那么它工作正常。

4

1 回答 1

0

结果jsonstruts2-json-plugin处理,序列化整个 Action

那么你也能:

  1. 仅从序列化操作中读取所需的对象:

    $http.get('IcdCodesAction')
    .success(function(response){
         console.log("this is the serialzied action -> " + response);
         console.log("this is what I want:  " + response.icdCodes);
         $scope.icdcodes = response.icdCodes;
    });
    

    或者

  2. 使用结果的root属性json来指定要序列化的单个元素:

    <action name="IcdCodesAction" class="com.emr.action.IcdAction" >    
        <result type="json">
            <param name="root">icdCodes</param>
        </result>
    </action>
    
于 2015-12-23T16:07:38.400 回答