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路线,但那只是我自己。