【发布时间】:2013-11-11 21:26:36
【问题描述】:
出于安全目的,我们更新到 Struts 2.3.15.1。当我们这样做时,我们注意到我们失去了一些使用 jsp 中的点表示法设置值的能力。如果我们有一个采用 Foo 类的地图并且 Foo 有一个 Bar 类,那么我们之前已经成功地使用隐藏字段为 Foo 设置 Bar 类。当我们更新时,Bar 类现在显示为 null 而之前 Bar 类(在下面的示例中)将为 Foo 创建并赋予 12 的 id 值。我知道这类似于 2.3.15.1 上的问题未设置 hashmap 值,但该帖子中的建议已尝试但未成功:
[Upgrading to struts 2.3.15.1 does not set HashMap values on action class
是否需要在我们的 jsp 中使用某种语法来获取新版本 Struts 的先前结果?
类 Foo
private Bar bar;
private String name;
public Bar getBar(){
return bar;
}
public void setBar(Bar bar){
this.bar = bar;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
类栏
private int id
public int getId(){
return id;
}
public void setId(int id){
this.id = id;
}
Class ActionClass{
private Map<String, Foo> userInputMap;
public Map<String, Foo> getUserInputMap(){
return userInputMap;
}
public void setUserInputMap(Map<String, Foo>, userInputMap){
this.userInputMap = userInputMap;
}
}
input.jsp
<s:hidden name="foo.userInputMap<'first_map_key'>.bar.id" value="12" />
<s:textarea name="foo.userInputMap<'first_map_key'>.name />
【问题讨论】:
-
为了成功的生活总是缩进代码。