Can JSP EL do direct attribute access

后端 未结 1 1075
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 05:22

This really surprised me ! I have the following code in my JSP.


This code was wor

1条回答
  •  终归单人心
    2021-01-21 06:00

    JSP EL relies strictly on Java Bean specification, so it cannot use other conventions to access property values.

    Actually, you can read about this is StackOverflow EL tag description

    So it's possible to invoke non-getter methods(not attributes) but only from certain EL vesion:

    Since EL 2.2, which is maintained as part of Servlet 3.0 / JSP 2.2 (Tomcat 7, Glassfish 3, JBoss AS 6, etc), it's possible to invoke non-getter methods, if necessary with arguments.

    E.g. ${bean.find(param.id)} with

    public Something find(String id) {
        return someService.find(id);
    }
    

    0 讨论(0)
提交回复
热议问题