gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 14:45:07 25 4
gpt4 key购买 nike

我有一个列表形式的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com