具有斜杠中断路由的节点JS路由参数

时间:2015-02-15 19:09:16

标签: javascript node.js url-routing

我有以下路由定义:

$urlRouterProvider.otherwise('/home');

$stateProvider
    .state('home', {
        url: '/home',
        views: {
            "mainView":   {templateUrl: './partials/home.html'}
            }
        })
    .state('page', {
        url: '/page/:pageResource',
        views: {
            "mainView":   {templateUrl: './partials/page.html'}
            }
        })

在home.html上我有这个ui-serf系列:

<a ui-sref="page({pageResource: '{{page.resource}}'})">

现在,当我将page.resource发送为pageRest/1时,我被重定向到:
http://localhost/page/pageRest/1
因为home而将我送回otherwise

此外,尝试将其编码为pageRest%2F1(如此处ExpressJS Route Parameter with Slash所示)并没有帮助。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

发现问题后,我试图在浏览器中粘贴网址而不知道它会自行解码网址编码。

发送双重编码的URL固定它:
http://localhost/page/pageRest%252F1

相关问题