将列表从 java 转换为 html 中的下拉菜单
Convert List from java to a dropdown menu in html
我从 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 代码中以列表形式输出
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();
}