0

urlManager为了接受字符串ID ,正确的规则是什么?它在 actionView 上显示错误 404。网址:/sampleSite/index.php/transaction/I201303001

这就是我的urlManager样子:

        'urlManager'=>array(
        'urlFormat'=>'path',
        'showScriptName'=>true,
        'rules'=>array(

            '<controller:\w+>/<id:\d+>'                     =>'<controller>/view',  
            '<controller:\w+>/<action:\w+>/<id:\d+>'    =>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>/<id:>'       =>'<controller>/<action>', 
            '<controller:\w+>/<action:\w+>'             =>'<controller>/<action>',

        ),
    ),

提前致谢!

4

2 回答 2

1

尝试使用 regExp 接受任何字符串(包括数字)

'rules'=>array(

        '<controller:\w+>/<id:[a-zA-Z0-9-]+>'                     =>'<controller>/view',  
        '<controller:\w+>/<action:\w+>/<id:\d+>'    =>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>/<id:>'       =>'<controller>/<action>', 
        '<controller:\w+>/<action:\w+>'             =>'<controller>/<action>',

    ),
于 2013-03-14T17:43:50.280 回答
0
'rules'=>array(
            '<module:\w+>/<controller:\w+>/<id:\w+>'                     =>'<module>/<controller>/view',  
            '<module:\w+>/<controller:\w+>/<action:\w+>/<id:\w+>'    =>'<module>/<controller>/<action>',
            '<module:\w+>/<controller:\w+>/<action:\w+>'             =>'<module>/<controller>/<action>',
            '<controller:\w+>/<id:\w+>'                     =>'<module:\w+>/<controller>/view',  
            '<controller:\w+>/<action:\w+>/<id:\w+>'    =>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'             =>'<controller>/<action>',

        ),
于 2013-03-14T05:53:13.287 回答