How can I pass an object to a JSP tag?

后端 未结 4 1082
隐瞒了意图╮
隐瞒了意图╮ 2021-02-11 19:18

I have a JSP page that contains a scriplet where I instantiate an object. I would like to pass that object to the JSP tag without using any cache.

For example I would

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-11 20:16

    For me expression language works only if I make that variable accessible, by putting it for example in page context.

    <%  Object myObject = new Object();
        pageContext.setAttribute("myObject", myObject);
    %>
    
    

    Otherwise tas receives null.

    And works with no additional effort. Also <%=%> gives jsp compile-time type validation, while El is validated only in runtime.

提交回复
热议问题