简体   繁体   中英

Symfony 2 routing with defaults values

i've a problem with my routing.yml in Symfony. When i put a defaults value it's return me and empty value. I dont knopw why he does it. I do it like Symfony's doc but problem persist http://symfony.com/doc/current/book/routing.html

lapille_plateform_homepage:
        path:     /{page}
        defaults: 
            _controller: LAPILLEPlateformBundle:Advert:index
            page: 1
        requirements:
            page: \d*

and my error it's an empty variable like that Symfony error

Thanks a lot for you help.

Alexandre

SOLVED

Change requirements

requirements:
    page: \d*

by

requirements:
    page: \d+

thx all

Try this :

lapille_plateform_homepage:
        path:     /{page}
        defaults: { _controller: LAPILLEPlateformBundle:Advert:index, page: 1}
        requirements:
            page: \d*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM