JSTL Session Lookup - Key Has Periods

寵の児 提交于 2019-12-07 02:48:19

问题


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 tried

${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.


回答1:


Use square bracket syntax.

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



来源:https://stackoverflow.com/questions/2541445/jstl-session-lookup-key-has-periods

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!