Pass a JSP variable as parameter to javascript function

前端 未结 2 1305
别跟我提以往
别跟我提以往 2021-01-12 05:37

I have a function defined inside the script tags of head.(in a JSP) I want to declare a string variable in the JSP and pass it as a parameter to this function



        
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-12 06:15

    If you want to avoid scirplet, you can use expression language by putting it between single quotes.

    onclick="pagetype('${uname}')";
    

    without the quotes, it tries to look for a variable with name same as the value of uname.

    PS: Used the chrome/firefox dev-tools debugging to find out what's going wrong.

提交回复
热议问题