Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery JSP中fmt消息键的动态变化_Jquery_Html_Jsp_Frontend - Fatal编程技术网

Jquery JSP中fmt消息键的动态变化

Jquery JSP中fmt消息键的动态变化,jquery,html,jsp,frontend,Jquery,Html,Jsp,Frontend,我正试图通过脚本来修改文本。我已经准备好了函数,但不知道如何更改键 <script type="text/javascript"> jQuery(function($) { let attachmentMaxSizeLimitKilobytes = ${sizeLimit}; let hasSpecificRole = ${hasSpecificRole}; $(function() { if(hasS

我正试图通过脚本来修改文本。我已经准备好了函数,但不知道如何更改键

<script type="text/javascript">
    jQuery(function($) {
        let attachmentMaxSizeLimitKilobytes = ${sizeLimit};
        let hasSpecificRole = ${hasSpecificRole};

        $(function() {
            if(hasSpecificRole){
                //the key inside label should be "text:test:displayNormalText"
            } else {
                //the key inside label should be "text:test:differentText"
            }
        });
    };
</script>

<test:main>
    //boilerplate omitted
    <label for="conditions"><fmt:message key="text:test:displayNormalText" bundle ="${bundle}/></label>
</test:main>
你知道我该怎么做吗?

你不能

JS在客户机上计算,JSP在服务器上计算


您需要在JS中创建一些将键映射到字符串的东西,这也可以在JSP中完成,例如,将带有键名的JS对象呈现到呈现的字符串中,记住它们需要JavaScript转义。

因此,作为一种解决方法,我可以复制标签。在第一个分配键文本:test:displayNormalText中,在第二个分配键文本:test:displayNormalText中,使用不同的id。然后执行如下操作:$firstShow.hide;$secondShow.show;等等,你可以,有点恶心。我会选择render JS路线,但那只是我自己。