gpt4 book ai didi

java - Tomcat 7.0.42 -> 7.0.47 在 EL-Escaping 中发生了什么变化?

转载 作者:搜寻专家 更新时间:2023-11-01 00:56:53 25 4
gpt4 key购买 nike

tomcat 7.0.42 -> 7.0.47 中的 EL-Escaping 发生了什么变化?

我有一个包含标签:

<jsp:include page="/WEB-INF/jsp/elements/dataview.jspx">
<jsp:param name="customParameter" value="{id:${object.id},action:\'${action}\'}" />
</jsp:include>

dataview.jspx 包含

<script type="text/javascript">
var customParameter = '${param.customParameter}';
</script>

在 tomcat 7.0.42 中它呈现为:

var customParameter = '{id:4,action:\'add\'}';

但是在 47 中它呈现这个:

var customParameter = '{id:4,action:\&#039;add\&#039;}';

发生了什么变化?我现在如何输出我的 js 变量?

最佳答案

我认为 Tomcat 7.0.47 是正确的。这是 Tomcat 7.0.42 的一个错误。针对您的情况的解决方案是使用 JSTL 函数用单引号将操作值包装起来。

  1. JSTL函数

    公共(public)类函数{

    public static String quote(String str) {
    if (str == null) {
    return null;
    }
    return ('\'' + str + '\'');
    }

  2. 使用 uri 为函数创建 TLD:' http://www.myapp.com/functions ' 前缀是 tf

  3. 使用你的函数

    Action :${tf:quote( Action )}

    var customParameter = ${tf:quote(param.customParameter)};//Eclipse 会对此发出警告,但它是有效的使用。

    这将生成这样的 JS 代码

    var customParameter = 'your_action_value';

关于java - Tomcat 7.0.42 -> 7.0.47 在 EL-Escaping 中发生了什么变化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20332866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com