HTML表单未在Velocity中编码搜索的URL

HTML表单未在Velocity中编码搜索的URL,html,forms,urlencode,velocity,Html,Forms,Urlencode,Velocity,我对搜索查询的URL编码有问题,我在模板中有这个问题 <form method="GET" action="$req.contextPath/plugins/peopledirectory/search.action"> <div class="greyboxfill" style="width: 420px"> <input type="hidden" name="pageId" value="$pageId"/> &

我对搜索查询的URL编码有问题,我在模板中有这个问题

<form method="GET" action="$req.contextPath/plugins/peopledirectory/search.action">
    <div class="greyboxfill" style="width: 420px">
        <input type="hidden" name="pageId" value="$pageId"/>
        <input type="text" name="search" id="search" size="30" value="$search"/>
        <input type="submit" name="searchbtn" value="Pesquisar">
    </div>
</form>

问题是,当我单击submit按钮时,搜索字符串不是URL编码的,如果我搜索像ME&A这样的东西,它只搜索我。速度中是否需要任何定义来实现这一点


我在网上看到表单HTML标记有一个内部URL编码,为什么在这种情况下不起作用?

最好的办法是使用from显式地转义字符串。这是一个额外的库,您需要下载它,然后将其包含在velocity上下文中

然后,URL编码与以下内容一样简单:

$escape.url($search)

这看起来与速度无关。您是否在浏览器的url字段中看到编码数据?我看到您的表单不是英文的,可能您键入了不同编码的
&
字符,使它无法识别?