Jira Rest Client的JSON响应问题

时间:2015-07-23 20:45:00

标签: java json jira-rest-api

当我使用以下方法时:

public String getProjectList() {
    projNames = new ArrayList<>();
    projNames.add("Project1");
    projNames.add("Project2");
    projNames.add("Project3");
    return new Gson().toJson(projNames);

在以下代码中:

 $(document).ready(function() {
        $.getJSON('DBDropDown', function(resp) { // on sucess
            var $select = $('#someselect');
            $select.find('option').remove();
            $select.prepend("<option value='Select Project'></option>").val('');
            $.each(resp, function(key, value) { // Iterate over the JSON object.
                $('<option>').val(key).text(value).appendTo($select); // Create HTML <option> element, set its value with currently iterated key and its text content with currently iterated item and finally append it to the <select>.
            });
        }).fail(function() { // on failure
            alert("Request failed.");
        });
    });

我的JSP调用是:

response.getWriter().write(MusicDatabase
                .getInstance()
                .getProjectList()

我可以获得下拉菜单。但是,当我使用此方法代替getProjectList时,我在检查chrome开发人员工具和调试时没有得到响应。

public String Names() throws URISyntaxException{
    names = new ArrayList<>();
    URI uri = new URI("https://jira.xxxxx.com");
    JiraRestClientFactory jrcf = new AsynchronousJiraRestClientFactory();
    JiraRestClient jrc = jrcf.createWithBasicHttpAuthentication(uri, "xxx", "xxxx");

    Iterable<BasicProject> allproject = jrc.getProjectClient().getAllProjects().claim();
    for(BasicProject project : allproject){
        names.add(project.getName());
    }

    return new Gson().toJson(names);
}

当我已经拥有所有需要的类时,我没有得到任何响应和控制台抛出ClassDefNotFound异常。如果您遇到过这类问题,请帮助我。

由于

0 个答案:

没有答案
相关问题