EL表达式的js函数传参问题

<!Doctype html>
<html>
    <head>
        <title>js的传参问题</title>
        <script type="text/javascript">
            function get(username) {
                alert(username);
            }
        </script>
    </head>
    <body>
        <input type="button" value="点我" onclick="get(${user.username })"/>
    </body>
</html>    

形如上面的代码,因为${user.username }得到的是字符串类型,假设得到的值为zhangSan。这样get(${user.username})就相当于get(zhangSan),但是这样写的js函数根本就不会执行。要写成下面的形式,js函数才会执行。当时因为这个问题,困扰我半天。。。。。。

<!Doctype html>
<html>
    <head>
        <title>js的传参问题</title>
        <script type="text/javascript">
            function get(username) {
                alert(username);
            }
        </script>
    </head>
    <body>
        <input type="button" value="点我" onclick="get('${user.username}')"/>
    </body>
</html>
原文地址:https://www.cnblogs.com/xphDeV/p/6227384.html