0
我期待下面的JavaScript函數來重定向到我的路線文件相匹配的網址。窗口位置未正常工作
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
感謝這個解釋。但是,我怎樣才能重定向到'localhost:8080/tasks/'? '了window.location = 「本地主機:9000 /任務/」 + address'仍然重定向我'HTTP://本地主機:9000 /任務哈希= 2014281623' –
2013-02-17 23:38:06
感謝您將上述評論?如果你嘗試使用encodeURI(uri),那麼怎麼樣? – 2013-02-17 23:46:10
即使'是encodeURI(URI)',它仍然帶我去'的http://本地主機:9000 /任務哈希= 2014281623' – 2013-02-18 00:10:21