&安培;未被编码为&使用tomcat 7.0.47

时间:2013-11-20 18:19:02

标签: tomcat spring-mvc urlencode spring-roo

问题是,对于某些tomcat服务器,链接标签是&在href值中被翻译为&当页面显示但与其他tomcat 7.0.47不同时,它看起来很奇怪,因为它应该工作。

我用这个:

<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<jsp:directive.page pageEncoding="UTF-8"/>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=8"/>
</head>

但它继续没有工作他的tomcat版本。

我使用的是spring-mvc,项目是使用spring-roo配置的。

此自定义标记中出现问题。

 <menu:item id="fi_user_username" messageCode="global_menu_find"
                       url="/movies?find=ByMoviename&amp;form"
                       z="Pt1/VjKgu7t6Aha3OJt4uC0yZR4="/>

自定义标记网址内是$ {url}。

            <spring:url value="${url}" var="menu_item_url"/>
            <a href="${menu_item_url}" title="${fn:escapeXml(label)}" id="${fn:escapeXml(id)}_a">
            <c:out value="${label}"/>

提供给浏览器的网站显示如下元素:

<a id="fi_movie_moviename_a" title="Find by Moviename" href="/movie-server/movies?find=ByMoviename&amp;form" class="selected_movie_submenu">Find by Movie name</a>

Tomcat具有默认配置。

感谢您的帮助。

2 个答案:

答案 0 :(得分:4)

从7.0.42升级到7.0.47后,我遇到了同样的问题。看起来“Tomcat”和Spring标签都在逃避&

要阻止Spring转义该网址,您可以将htmlEscape="false"添加到url代码。

答案 1 :(得分:0)

也有这个问题,正在使用上面提到的htmlEscape="false"工作。它似乎在Tomcat 7.0.50中修复,虽然我没有在更改日志中看到它:

http://tomcat.apache.org/tomcat-7.0-doc/changelog.html

然而,我可能错过了它。

相关问题