java - 将 List 从 java 转换为 html 中的下拉菜单

标签 java html jira-rest-java-api

我有一个列表形式的 java 代码输出

public class getProjectList {
    final String username = "username";
    final String password = "password";
    final String ProjectNames = null;

    public getProjectList() throws URISyntaxException, InterruptedException, ExecutionException {
        final URI jiraserverURI = new URI("https://jira.xxxx.com");
        final JiraRestClientFactory restClientfactory = new AsynchronousJiraRestClientFactory();
        final JiraRestClient restClient =
          restClientfactory.createWithBasicHttpAuthentication(jiraserverURI,username,password);
        final Iterable<BasicProject> allproject = restClient.getProjectClient().getAllProjects().get();
        final String ProjectNames = allproject.toString();
        System.out.println(ProjectNames);
    }
}

我想将此代码的输出用作下拉菜单项。需要帮助。谢谢你

最佳答案

String projectsToHtmlOptions(String projectNames,String separator){
   StringBuilder sb = new StringBuilder();
   sb.append("<select>");
   for(String project:projectNames.split(separator)
      sb.append("<option value=\""+project+"\">"+project+"</option>");
   sb.append("</select>");
   return sb.toString();
}

关于java - 将 List 从 java 转换为 html 中的下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31465872/

相关文章:

java - 对象化 v5 : Profile is not a supported property type

javascript - 最大化CSS中列的大小

rest - Spring boot 和 Jira REST API 在 maven 中给出依赖错误

java - 无法访问 Rest-Resource 请求 url

java - JUnit 4.11 不显示参数值但显示索引

java - 为 BottomNavigationView 中的导航项添加边距

java 嵌入式 OS X 应用程序 VS 系统安装的 Java

javascript - 在 SVG 形状中居中 SVG 文本,在刷新之间保存 JavaScript 变量值

jquery - 弹出 div 以保持在可见屏幕的中心

node.js - 在 "Awaiting Release"处查询 JIRA API 的所有问题