weixin_42299504 2009-01-07 22:02
浏览 232
已采纳

Struts2版本.不能接收小写变量名为shr的数据值,

我使用Map作为我的接收容器,shr是一个key.

当我通过地址: http://localhost:9999/ta/aa/test.do?map.shr=feng 来传递数据时.

问题: 打印不出shr参数.的值.这是为什么? 大写可以接收的

为什么map接收不了shr属性值呢,其它的属性都能接收.



public class TestAction{   

public Map<string,string> map = new HashMap<string,string>();  

public Map getMap()//.....set and get..

public String view(){

System.out.println(this.map); //打印不出shr属性

return "";

}

}

public class TestAction{

public Map<string,string> map = new HashMap<string,string>();

public String view(){
System.out.println(this.map); //打印不出shr属性
return "";

}

}

为什么map接收不了shr属性呢,其它的属性都能接收.
  • 写回答

1条回答 默认 最新

  • Candyut 2009-01-08 13:40
    关注

    http://localhost:9999/ta/aa/test.do?map.shr=feng
    改为:
    http://localhost:9999/ta/aa/test.do?map[shr]=feng

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?