开发者

JSTL Session Lookup - Key Has Periods

开发者 https://www.devze.com 2022-12-24 08:13 出处:网络
I am working with some legacy code, and at some point there is a key in the session that is something like

I am working with some legacy code, and at some point there is a key in the session that is something like

session.setAttribute("com.org.something.Object",someObject);

Now trying to access this in a jsp using jstl is a bit difficult becuase if I tried it like I normally would I would do:

${sessionScope.com.org.something.Object.someFieldGetter}

As most of us can imagine it will fail because there is no com object in session scope. I also tri开发者_如何学JAVAed

${sessionScope.'com.org.something.Object'.someFieldGetter} 

And a parsing error was thrown.

Does anyone know how to resolve this so that I can correctly get the object similar to session.getAttribute("com.org.something.Object") but through jstl?

thank you.


Use square bracket syntax.

${sessionScope['com.org.something.Object'].someFieldGetter} should do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消