您好我试图发布地图但我仍然无法让它发挥作用......有人可以帮助我吗?
我的代码基于此示例:spring-mvc-hashmap-form
这是我的实施:
JSP(这是在我的模型中使用map的形式):
<c:set var="var1" value="${map['product.h1.title']}"/>
<input style="display: none;" type="text" name="mapConfigs['${var1.key}']" value="${var1.id}"/>
<input style="display: none;" type="text" name="mapConfigs['${var1.key}']" value="${var1.key}"/>
<input type="text" class="titulos" name="mapConfigs['${var1.key}']" value="${var1.value}"/>
DTO表格:
public class MapConfigurationsForm {
private Map<String, SystemConfiguration> mapConfigs;
public MapConfigurationsForm(){
this(null);
}
public MapConfigurationsForm(Map<String, SystemConfiguration> mapConfigs) {
this.mapConfigs = mapConfigs;
}
public Map<String, SystemConfiguration> getMapConfigs() {
return mapConfigs;
}
public void setMapConfigs(Map<String, SystemConfiguration> mapConfigs) {
this.mapConfigs = mapConfigs;
}
这是我期望在我的控制器中得到的:
@RequestMapping(value = "/oferta_producto", method= RequestMethod.POST)
public String postOfertaProducto(HttpServletRequest request, @ModelAttribute("configs") MapConfigurationsForm confs, ModelMap map) {
SystemConfiguration:
public class SystemConfiguration {
private Long id;
private String key;
private String value;
//Getter.... Setter... Etc...