【发布时间】:2018-04-17 16:26:40
【问题描述】:
Java 代码包含以下内容:
@ModelAttribute("countries")
public List<Country> initializeCountries() {
List <Country> countries = countryService.findAllCountrys();
return countries;
}
我已使用以下代码成功填充国家/地区:
<form:select path="country" id="country">
<form:option value="">Select Country</form:option>
<form:options items="${countries}" itemValue="countryCode" itemLabel
= "countryName" />
</form:select>
<form:errors path="country" cssClass="error"/>
我有以下根据 countryCode 获取状态的代码:
List <State> states = countryService.findAllStatesOfCountry(countryCode);
我应该如何编写java代码和jsp代码来填充基于国家选择的状态下拉列表。在spring注解中不使用Ajax/javascript还有其他方法吗?试图找到这个选项。
如果不请提及完整的细节,因为我在 Ajax 方面已经尽力了。我是 Ajax 新手,因此请分享要加载到 jsp 文件中的 maven 依赖项、js 和 css 文件。
【问题讨论】:
标签: java spring jsp spring-mvc spring-annotations