我有如下的HTML標記,其中操作是在sammyjs定義路由的路由路徑中的一個的代碼:不能夠匹配現有路由路徑和獲取404未找到
<form id="loginform" action="#/login" method="post" class="form-horizontal">
<!-- input & hidden elements -->
<!-- submit button -->
</form>
如果上述觀點通過URL加載像「本地主機:XXX /帳號/登錄」,當我提交以上表格,sammyjs記錄錯誤,這是無法找到的路線:
[Thu Apr 24 2014 13:52:39 GMT+0100 (GMT Daylight Time)] #shell 404 Not Found get /Account/Login#/login
Error {message: "404 Not Found get /Account/Login#/login ", stack: "Error↵ at Object.Sammy.Application.$.extend.err…/localhost:36141/Scripts/Vendor/require.js:132:23"}
message: "404 Not Found get /Account/Login#/login "
stack: "Error↵ at Object.Sammy.Application.$.extend.error (http://localhost:36141/Scripts/Vendor/sammy-0.7.4.js:1346:47)↵ at Object.Sammy.Application.$.extend.notFound (http://localhost:36141/Scripts/Vendor/sammy-0.7.4.js:1335:22)↵ at Object.Sammy.Application.$.extend.runRoute (http://localhost:36141/Scripts/Vendor/sammy-0.7.4.js:1179:21)↵ at Object.Sammy.Application.$.extend._checkLocation (http://localhost:36141/Scripts/Vendor/sammy-0.7.4.js:1365:25)↵ at Object.Sammy.Application.$.extend.run (http://localhost:36141/Scripts/Vendor/sammy-0.7.4.js:971:12)↵ at http://localhost:36141/Scripts/App/common.js:36:19↵ at Object.context.execCb (http://localhost:36141/Scripts/Vendor/require.js:1650:33)↵ at Object.Module.check (http://localhost:36141/Scripts/Vendor/require.js:866:51)↵ at Object.<anonymous> (http://localhost:36141/Scripts/Vendor/require.js:1113:34)↵ at http://localhost:36141/Scripts/Vendor/require.js:132:23"
__proto__: d
我無法理解爲什麼sammy尋找「 /帳戶/登錄#/登錄「,因爲我的表單操作設置爲」#/ login「。
我也試圖改變下面的錯誤上面提到的,像「#/登錄」到「/帳號/登錄#/登錄」路由路徑我的劇本,但我再次得到了同樣的錯誤如上面鏈接所述。
this.post('#/login', function (context) {
//process
});
與其他鏈接或表單標籤相同。我想要使用的哈希標籤後綴爲URL中的任何內容,如「/ Account/Login#{/ any_hash_tag}」。 我該怎麼做才能解決這個問題?
但是,如果視圖是通過像「localhost:xxx /」這樣的url加載的,並且沒有其他路由參數,那麼一切正常。
這將是很高興知道是否有什麼我做錯了。
乾杯
您正在使用相對鏈接...如果您正在查看「www.mysite.com/pages/index.html」,並且存在與「about.html」href鏈接,您會期望在哪裏那要帶你? 'www.mysite.com/about.html'或'www.mysite.com/pages/about.html'? –
@JasonP我不會在任何地方寫相關鏈接。它的sammy路由庫增加了當前的url + form的動作(「#/ login」),所以它變成了「/ Account/Login#login」。即使我無法弄清楚這一點,因爲我期望sammy路由尋找「#/ login」路徑。 –
@Yoda你是__absolutely__使用相對路徑。研究URL碎片如何工作。 – rockerest