我期望下面的JavaScript函数重定向到与我的路由文件匹配的URL。
function getUrl()
{
var hash= $('#hashText').val();
// When the user has not entered a hash, alert to inform them.
if (!hash)
{
alert("Please enter a hash first.");
}
else
{
alert("Redirecting to ... http://localhost:8080/tasks/" + hash);
window.location = "http://localhost:8080/tasks/" + hash;
}
}
下面是我的路由文件中相应的路由条目。
GET /tasks/:hash controllers.Application.getTask(hash: Int)
然而,这一职能的结果是:
http://localhost:9000/tasks?hash=2014281623
发布于 2013-02-17 10:37:13
如果您将代码更改为:
var url = 'http://localhost:9000/tasks/';
url += escape(hash);
window.location = url;
https://stackoverflow.com/questions/14924411
复制相似问题