You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Niral Trivedi <ni...@gmail.com> on 2012/04/14 20:15:37 UTC

Accessing Map of Map in struts 2.3.1.2

Hi All,

I have just now upgraded from Struts 2.0.11 to struts 2.3.1.2 version and
running in to weird issue.

Basically, I have Object having HashMap holding HashMap. Something like
below :

public class TestVO {
         private HashMap<String, HashMap> firstMap;


         //I've setter/getter in real code but omitting here for simplicity.
}

My Action class goes as below :

public class MyAction extends ActionSupport {
        public TestVO testVO;

        public TestVO getTestVO() {
                  return this.testVO;
        }
        public void setTestVO(TestVO testVO) {
                 this.testVO = testVO;
        }

        public String execute() {
               HashMap<String, HashMap> firstMap = new HashMap<String,
HashMap>();
               HashMap<String, String> secondMap = new HashMap<String,
String>();


               secondMap.put("FIRST_KEY", "firstValue");
               secondMap.put("SECOND_KEY", "secondValue");

               firstMap.put("KEY1", secondMap);

               testVO.setFirstMap(firstMap);

               return "success";
        }
}

Now with above VO and class, I am doing below in my JSP and it is not
working after upgrade.

<s:property value="testVO.FirstMap.FIRST_KEY" />

Now above code was perfectly working fine with old struts 2.0.11 jar but
after upgrading this doesn't seem to be working.

I have tried doing <s:property value="testVO.FirstMap.['FIRST_KEY']" /> and
<s:property value="%{testVO.FirstMap.['FIRST_KEY]'}" /> but to no luck.

Am I missing something here ? Is there a different way to access Map of Map
with latest version ?

Please let me know if anyone has any idea.

Thank you.

Re: Accessing Map of Map in struts 2.3.1.2

Posted by vEnkaTa mohAna rAo SriperumbUdUru <mo...@gmail.com>.
Put your project in development mode. struts.devMode = true

and use <s:debug/> tag, It will display the objects available in the
current. This will confirms that whether you getting proper data are not.

or append your url with
http://localhost:8080/MyProject/IloveStruts2Action?debug=xml

OGNL interactive console is there. But it's never worked for me.

http://struts.1045723.n5.nabble.com/OGNL-runtime-viewer-td3477295.html

If you are getting proper data then you have to play with OGNL.



On Sun, Apr 15, 2012 at 1:23 AM, Niral Trivedi <ni...@gmail.com> wrote:

> yes. i m accessing map. But I was just browsing struts site and found that
> article so wondering whether this could be related to my issue as this link
> also states that some OGNL security issue fixed.
>
> On Sat, Apr 14, 2012 at 3:51 PM, Dave Newton <da...@gmail.com>
> wrote:
>
> > No, that's related to static methods; I thought you were accessing a map.
> >
> > On Sat, Apr 14, 2012 at 3:49 PM, Niral Trivedi <ni...@gmail.com>
> wrote:
> >
> > > I do not see anything in logs.
> > >
> > > Also, I find this link
> > >
> > >
> >
> https://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-RefactorusageofstaticmethodsviaOGNL
> > > but in my case it's not a static method. and the internal link from
> here
> > to
> > > jira issue couldn't open.
> > >
> > > So, is this related to my issue ?
> > >
> > > 2012/4/14 Łukasz Lenart <lu...@googlemail.com>
> > >
> > > > 2012/4/14 Niral Trivedi <ni...@gmail.com>:
> > > > > Am I missing something here ? Is there a different way to access
> Map
> > of
> > > > Map
> > > > > with latest version ?
> > > >
> > > > It can be a side effect of security changes to OGNL and Struts2, do
> > > > you see anything unusual in logs ? Try to increase log level to
> Debug.
> > > >
> > > >
> > > > Regards
> > > > --
> > > > Łukasz http://www.lenart.org.pl/
> > > > mobile +48 606 323 122, office +27 11 0838747
> > > > Warszawa JUG conference - Confitura http://confitura.pl/
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > >
> >
>

Re: Accessing Map of Map in struts 2.3.1.2

Posted by Niral Trivedi <ni...@gmail.com>.
yes. i m accessing map. But I was just browsing struts site and found that
article so wondering whether this could be related to my issue as this link
also states that some OGNL security issue fixed.

On Sat, Apr 14, 2012 at 3:51 PM, Dave Newton <da...@gmail.com> wrote:

> No, that's related to static methods; I thought you were accessing a map.
>
> On Sat, Apr 14, 2012 at 3:49 PM, Niral Trivedi <ni...@gmail.com> wrote:
>
> > I do not see anything in logs.
> >
> > Also, I find this link
> >
> >
> https://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-RefactorusageofstaticmethodsviaOGNL
> > but in my case it's not a static method. and the internal link from here
> to
> > jira issue couldn't open.
> >
> > So, is this related to my issue ?
> >
> > 2012/4/14 Łukasz Lenart <lu...@googlemail.com>
> >
> > > 2012/4/14 Niral Trivedi <ni...@gmail.com>:
> > > > Am I missing something here ? Is there a different way to access Map
> of
> > > Map
> > > > with latest version ?
> > >
> > > It can be a side effect of security changes to OGNL and Struts2, do
> > > you see anything unusual in logs ? Try to increase log level to Debug.
> > >
> > >
> > > Regards
> > > --
> > > Łukasz http://www.lenart.org.pl/
> > > mobile +48 606 323 122, office +27 11 0838747
> > > Warszawa JUG conference - Confitura http://confitura.pl/
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
>

Re: Accessing Map of Map in struts 2.3.1.2

Posted by Dave Newton <da...@gmail.com>.
No, that's related to static methods; I thought you were accessing a map.

On Sat, Apr 14, 2012 at 3:49 PM, Niral Trivedi <ni...@gmail.com> wrote:

> I do not see anything in logs.
>
> Also, I find this link
>
> https://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-RefactorusageofstaticmethodsviaOGNL
> but in my case it's not a static method. and the internal link from here to
> jira issue couldn't open.
>
> So, is this related to my issue ?
>
> 2012/4/14 Łukasz Lenart <lu...@googlemail.com>
>
> > 2012/4/14 Niral Trivedi <ni...@gmail.com>:
> > > Am I missing something here ? Is there a different way to access Map of
> > Map
> > > with latest version ?
> >
> > It can be a side effect of security changes to OGNL and Struts2, do
> > you see anything unusual in logs ? Try to increase log level to Debug.
> >
> >
> > Regards
> > --
> > Łukasz http://www.lenart.org.pl/
> > mobile +48 606 323 122, office +27 11 0838747
> > Warszawa JUG conference - Confitura http://confitura.pl/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Re: Accessing Map of Map in struts 2.3.1.2

Posted by Niral Trivedi <ni...@gmail.com>.
I do not see anything in logs.

Also, I find this link
https://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-RefactorusageofstaticmethodsviaOGNL
but in my case it's not a static method. and the internal link from here to
jira issue couldn't open.

So, is this related to my issue ?

2012/4/14 Łukasz Lenart <lu...@googlemail.com>

> 2012/4/14 Niral Trivedi <ni...@gmail.com>:
> > Am I missing something here ? Is there a different way to access Map of
> Map
> > with latest version ?
>
> It can be a side effect of security changes to OGNL and Struts2, do
> you see anything unusual in logs ? Try to increase log level to Debug.
>
>
> Regards
> --
> Łukasz http://www.lenart.org.pl/
> mobile +48 606 323 122, office +27 11 0838747
> Warszawa JUG conference - Confitura http://confitura.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Accessing Map of Map in struts 2.3.1.2

Posted by Łukasz Lenart <lu...@googlemail.com>.
2012/4/14 Niral Trivedi <ni...@gmail.com>:
> Am I missing something here ? Is there a different way to access Map of Map
> with latest version ?

It can be a side effect of security changes to OGNL and Struts2, do
you see anything unusual in logs ? Try to increase log level to Debug.


Regards
-- 
Łukasz http://www.lenart.org.pl/
mobile +48 606 323 122, office +27 11 0838747
Warszawa JUG conference - Confitura http://confitura.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org