简体   繁体   中英

How to access properties that are restricted in EL / JSP

I have this line in one of my JSPs:

<fmt:message key="label.user.request.type.${requestEntry.key.class.simpleName}"/>

Used to work perfectly up until I upgraded Jetty to v9.2.2. Now I guess the JSP library has been updated, which makes java reserved words (like default , class etc illegal identifiers.

The above code comes from rendering a Map , and I use the getClass() getter - which by some sort of magic becomes .class. - which is a reserved word.

I'm kind of stuck - how can I get around this problem? I'd rather not refactor the entire file, since the current implementation is pretty neat and easy to read.

If there ARE ways of making this work, please let me know. I ended up creating a getClazz() getter in the class used as a key in this map, and then just using that instead.

However, I find this workaround a tad bit hacky - would be nice to reference this getter some other way. So if you have another solution, please let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM