Map 在action里取不到key和valueStruts2定义的Map属性能自动set和get吗?action
private Map props = new HashMap(); // --------------------------------------------------------------------------------------------/ @Override
public String execute() throws Exception {
if (this.getProps().isEmpty()) {
System.err.println("true");
} else {
System.err.println("false");
} } // --------------------------------------------------------------------------------------------/ public Map getProps() {
return props;
} public void setProps(Map props) {
this.props = props;
}跟踪调试发现props根本什么也没有<s:form action="test.action">
<table><tr>
<td class="tdLabel">报销金额</td>
<td><input name="props(money)" type="text">
</td>
</tr>
</table>
</s:form>
private Map props = new HashMap(); // --------------------------------------------------------------------------------------------/ @Override
public String execute() throws Exception {
if (this.getProps().isEmpty()) {
System.err.println("true");
} else {
System.err.println("false");
} } // --------------------------------------------------------------------------------------------/ public Map getProps() {
return props;
} public void setProps(Map props) {
this.props = props;
}跟踪调试发现props根本什么也没有<s:form action="test.action">
<table><tr>
<td class="tdLabel">报销金额</td>
<td><input name="props(money)" type="text">
</td>
</tr>
</table>
</s:form>
存:
Map mapValue = new HashMap();
mapValue.put("key1", "value1");
mapValue.put("key2", "value2");取:
${mapValue.key1}
props.money这是props对象吧,Map的属性 props(动态值)
list="statusMap"
listKey="key" listValue="value" name="status" />
是action取页面的值,不是页面输出
后台还是那样取,应该可以,struts2中的ognl可以对map的键值对这样赋值,不只限于对象