symfony路由重定向到登录页面

时间:2015-10-15 11:13:25

标签: php symfony

我有一个简单的控制器动作:

/**
* @Route("/abc", name="abc")
*/
public function testAction($abc)
{
    return new Response($abc);
}

Security.yml:

security:
    ..

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4
            logout:       true
            anonymous:    true

    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/abc$, role: IS_AUTHENTICATED_ANONYMOUSLY}

但是当我去url / abc时,它会重定向到登录。我做错了什么?

2 个答案:

答案 0 :(得分:1)

首先,您必须在路线中使用占位符:

/**
 * @Route("/prefix_or_not/{abc}", name="your_route_name")
 */
public function testAction($abc)
{
    return new Response($abc);
}

答案 1 :(得分:0)

您应该将var ids = Array.prototype.slice.call(document.querySelectorAll('.Jicon')).map(function ( element ) { return element.id; }); 更改为#include <stdio.h> #include <string.h> void array_print (const int* arr, size_t size) { for(size_t i=0; i<size; i++) { printf("%d ", arr[i]); } printf("\n"); } void array_remove (int* arr, size_t size, size_t index, size_t rem_size) { int* begin = arr+index; // beginning of segment to remove int* end = arr+index+rem_size; // end of segment to remove size_t trail_size = size-index-rem_size; // size of the trailing items after segment memcpy(begin, // move data to beginning end, // from end of segment trail_size*sizeof(int)); memset(begin+trail_size, // from the new end of the array 0, // set everything to zero rem_size*sizeof(int)); } int main (void) { int array [8] = {3, 5, 6, 8, 2, 9, 10, 1}; const int size = sizeof(array) / sizeof(*array); array_print(array, size); array_remove(array, size, 3, 4); // from index 3, remove 4 items array_print(array, size); return 0; }

anonymous: true
相关问题