Java 如何在数据空间中添加输入表单(反馈)和非常长的数据?

Java 如何在数据空间中添加输入表单(反馈)和非常长的数据?,java,xml,dspace,Java,Xml,Dspace,我的老板想在反馈表单中添加一个选择表单,要求用户选择他/她的国家/地区。我可以通过以下方式实现这一目标: Select country = form.addItem().addSelect("country "); userType.setLabel("Country"); userType.addOption("","Please select your country"); userType.addOption("ABW","Aruba"); user

我的老板想在反馈表单中添加一个选择表单,要求用户选择他/她的国家/地区。我可以通过以下方式实现这一目标:

    Select country = form.addItem().addSelect("country ");
    userType.setLabel("Country");
    userType.addOption("","Please select your country");
    userType.addOption("ABW","Aruba");
    userType.addOption("AFG","Afghanistan");
    <----- Rest of countries from A to Z --->
    userType.setOptionSelected(parameters.getParameter("country",""));
    TextArea countryOther = form.addItem().addTextArea("countryOther");
    countryOther.setValue(parameters.getParameter("countryOther", ""));
Select country=form.addItem().addSelect(“国家”);
userType.setLabel(“国家”);
userType.addOption(“,”请选择您的国家”);
addOption(“ABW”、“Aruba”);
userType.addOption(“AFG”、“阿富汗”);
userType.setOptionSelected(parameters.getParameter(“国家”,“国家”);
TextArea countryOther=form.addItem().addTextArea(“countryOther”);
countryOther.setValue(parameters.getParameter(“countryOther”,下称“));

我希望避免将代码与非常长的国家列表混在一起。有没有其他办法,比如把国家名单放在一个单独的地方,然后直接提取这些信息?提前感谢。

一个简单的方法是创建一个配置文件:
config/modules/countries.cfg
并像配置属性一样填写您的列表:

ABW=Aruba
AFG=Afghanistan
...
然后使用
ConfigurationManager

Select country = form.addItem().addSelect("country ");
country.setLabel("Country");
country.addOption("", "Please select your country");

Enumeration<?> countries = ConfigurationManager.propertyNames("countries");
while (countries.hasMoreElements()) {
    String key = (String) countries.nextElement();
    String value = ConfigurationManager.getProperty("countries", key);
    country.addOption(key, value);
}
Select country=form.addItem().addSelect(“国家”);
国家。设置标签(“国家”);
country.addOption(“,”请选择您的国家”);
枚举国家=ConfigurationManager.propertyNames(“国家”);
而(countries.hasMoreElements()){
字符串键=(字符串)countries.nextElement();
字符串值=ConfigurationManager.getProperty(“国家”,键);
country.addOption(键、值);
}

一种简单的方法是创建一个配置文件:
config/modules/countries.cfg
并像配置属性一样填写您的列表:

ABW=Aruba
AFG=Afghanistan
...
然后使用
ConfigurationManager

Select country = form.addItem().addSelect("country ");
country.setLabel("Country");
country.addOption("", "Please select your country");

Enumeration<?> countries = ConfigurationManager.propertyNames("countries");
while (countries.hasMoreElements()) {
    String key = (String) countries.nextElement();
    String value = ConfigurationManager.getProperty("countries", key);
    country.addOption(key, value);
}
Select country=form.addItem().addSelect(“国家”);
国家。设置标签(“国家”);
country.addOption(“,”请选择您的国家”);
枚举国家=ConfigurationManager.propertyNames(“国家”);
而(countries.hasMoreElements()){
字符串键=(字符串)countries.nextElement();
字符串值=ConfigurationManager.getProperty(“国家”,键);
country.addOption(键、值);
}

一种简单的方法是创建一个配置文件:
config/modules/countries.cfg
并像配置属性一样填写您的列表:

ABW=Aruba
AFG=Afghanistan
...
然后使用
ConfigurationManager

Select country = form.addItem().addSelect("country ");
country.setLabel("Country");
country.addOption("", "Please select your country");

Enumeration<?> countries = ConfigurationManager.propertyNames("countries");
while (countries.hasMoreElements()) {
    String key = (String) countries.nextElement();
    String value = ConfigurationManager.getProperty("countries", key);
    country.addOption(key, value);
}
Select country=form.addItem().addSelect(“国家”);
国家。设置标签(“国家”);
country.addOption(“,”请选择您的国家”);
枚举国家=ConfigurationManager.propertyNames(“国家”);
而(countries.hasMoreElements()){
字符串键=(字符串)countries.nextElement();
字符串值=ConfigurationManager.getProperty(“国家”,键);
country.addOption(键、值);
}

一种简单的方法是创建一个配置文件:
config/modules/countries.cfg
并像配置属性一样填写您的列表:

ABW=Aruba
AFG=Afghanistan
...
然后使用
ConfigurationManager

Select country = form.addItem().addSelect("country ");
country.setLabel("Country");
country.addOption("", "Please select your country");

Enumeration<?> countries = ConfigurationManager.propertyNames("countries");
while (countries.hasMoreElements()) {
    String key = (String) countries.nextElement();
    String value = ConfigurationManager.getProperty("countries", key);
    country.addOption(key, value);
}
Select country=form.addItem().addSelect(“国家”);
国家。设置标签(“国家”);
country.addOption(“,”请选择您的国家”);
枚举国家=ConfigurationManager.propertyNames(“国家”);
而(countries.hasMoreElements()){
字符串键=(字符串)countries.nextElement();
字符串值=ConfigurationManager.getProperty(“国家”,键);
country.addOption(键、值);
}

谢谢,这很有效。我只是想知道为什么产生的下拉列表没有像配置文件中的值那样排序?谢谢,这很有效。我只是想知道为什么产生的下拉列表没有像配置文件中的值那样排序?谢谢,这很有效。我只是想知道为什么产生的下拉列表没有像配置文件中的值那样排序?谢谢,这很有效。我只是想知道为什么生成的下拉列表不像配置文件中的值那样排序?