How to pass an EL variable to javascript

后端 未结 4 898
一向
一向 2020-11-30 14:44

I have a variable ${bean.name} how can i pass it to a javascript var? I\'ve tried var name = \"${bean.name}\" and var name = ${bean.name}<

4条回答
  •  隐瞒了意图╮
    2020-11-30 15:22

    this doen't work either var name becomes the string "${bean.name}"

    Make sure that you're running a Servlet 2.4 capable container and that web.xml is declared as Servlet 2.4 or higher.

    
    
    
        
    
    
    

    This way EL will work in template text as well (without the need for JSTL ). It was namely introduced in Servlet 2.4 / JSP 2.0. Tomcat 5.5 is an example of a Servlet 2.4 container. If your container supports a higher servlet API version, e.g. 2.5 or 3.0, then you should declare the web.xml conform this version to benefit all newest features.

    You'll then also be able to do the following in the JSP:

    
    

提交回复
热议问题