有没有办法在Spring中使用JSP </string,>中的输入发布Map <string,object =“”>

时间:2013-10-08 15:38:01

标签: java spring jsp spring-mvc

您好我试图发布地图但我仍然无法让它发挥作用......有人可以帮助我吗?

我的代码基于此示例: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...

0 个答案:

没有答案