【发布时间】:2016-03-07 09:51:25
【问题描述】:
我不完全确定发生了什么,因为这是我第一次遇到这种问题,但由于某种原因,我的 Symfony2 项目中的一个特定页面在 app.php 上有一个重定向循环,但在 app_dev 上时.php,没关系。
页面名为/files,该页面的路由如下:
app_files_table:
path: /files
defaults: { _controller: AppBundle:File:list }
这个页面的控制器方法很简单:
public function listAction()
{
$em = $this->getDoctrine()->getManager();
$documents_repo = $em->getRepository('AppBundle:Documents');
$documents = $documents_repo->findAll();
return $this->render('AppBundle:tables:files.html.twig', array(
'files' => $documents
));
}
twig 模板只是一个标准布局,它与我的所有其他页面(扩展我的作为标题的基本文件)在主体中使用以下代码匹配:
{% if files is not empty %}
{% for file in files %}
<tr>
<th scope="row">{{ file.id }}</th>
<td>{{ file.name }}</td>
<td>{{ file.displayName }}</td>
<td>{{ file.product.model }}</td>
<td class="text-center">
<a class="btn btn-primary" href="{{ file_path }}/{{- file.name -}}" target="_blank" download><i class="fa fa-download"> </i></a>
<a class="btn btn-danger file-delete" data-confirm-title="Are you sure?" data-confirm-message="You will not be able to undo this action." href="javascript:deleteFile({{ file.id }});" id="delete_file_{{ file.id }}" data-toggle="tooltip" title="Remove File"><i class="fa fa-remove"> </i></a>
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="5">There are no files in the database</td>
</tr>
{% endif %}
我没有编辑 app.php、app_dev.php 和 .htaccess 文件——它们与安装框架时一样。我还清除了两次缓存,包括手动删除所有缓存文件 - 但重定向问题仍然存在。
这是其他人遇到并设法解决的问题吗?因为我很困惑为什么它应该在这个页面上发生 - 事实上,我什至尝试在模板渲染之前在控制器中放置一个 die() 语句,但同样的事情发生了,所以它必须与路由有关?
任何帮助表示赞赏。
谢谢
编辑 - 调试结果:路由器
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_purge ANY ANY ANY /_profiler/purge
_profiler_info ANY ANY ANY /_profiler/info/{about}
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
app_dashboard ANY ANY ANY /
app_user_dashboard ANY ANY ANY /user-dashboard
fos_user_security_login ANY ANY ANY /login
fos_user_security_check ANY ANY ANY /login_check
app_customers_table ANY ANY ANY /customers
app_orders_table ANY ANY ANY /orders
app_projects_table ANY ANY ANY /projects
app_products_table ANY ANY ANY /products
app_files_table ANY ANY ANY /documents
app_users_table ANY ANY ANY /users
app_categories_table ANY ANY ANY /categories
app_customer_view ANY ANY ANY /customer/{id}/{orderYear}
app_order_view ANY ANY ANY /order/{id}
app_project_view ANY ANY ANY /project/{id}
app_user_view ANY ANY ANY /user/{id}
app_customer_add ANY ANY ANY /customer/add
app_address_add ANY ANY ANY /address/add/{id}
app_order_add ANY ANY ANY /order/add
app_user_add ANY ANY ANY /user/new
app_stage_add ANY ANY ANY /stage/new
app_category_add ANY ANY ANY /category/new
app_document_add ANY ANY ANY /document/new/
fos_user_registration_register ANY ANY ANY /new-user
fos_user_security_logout ANY ANY ANY /logout
fos_user_registration_check_email ANY ANY ANY /check-email
fos_user_registration_confirm ANY ANY ANY /confirm/{token}
fos_user_registration_confirmed ANY ANY ANY /confirmed
fos_user_profile_show ANY ANY ANY /profile
fos_user_profile_edit GET|POST ANY ANY /profile-edit
app_missing_orders_table ANY ANY ANY /missing-orders
app_delete_item ANY ANY ANY /delete/{type}/{id}
app_calendar ANY ANY ANY /calendar
app_ajax_call ANY ANY ANY /ajax-call/{action}/{data}
app_customer_search ANY ANY ANY /customer-search
app_customer_get ANY ANY ANY /customer-get
app_product_search ANY ANY ANY /product-search
app_product_search_id ANY ANY ANY /product-search-by-id
app_product_get ANY ANY ANY /product-get
app_add_order ANY ANY ANY /add-order
app_print_job_label ANY ANY ANY /print-job-label/{id}
app_claim_task ANY ANY ANY /claim-task/{id}
app_complete_task ANY ANY ANY /complete-task/{id}
app_stages_edit ANY ANY ANY /edit-stages
app_category_edit ANY ANY ANY /edit-category/{id}
app_run_cron_task ANY ANY ANY /cron-generate-projects
remove_trailing_slash GET ANY ANY /{url}
fullcalendar_loader ANY ANY ANY /fc-load-events
fos_js_routing_js ANY ANY ANY /js/routing.{_format}
【问题讨论】:
-
你会被重定向到哪里?
-
你在 prod.log 中有什么?
-
它不会重定向到任何地方 - 我收到“页面未正确重定向”错误,就好像它试图找到正确的路线但只是来回走动。 Pawel - prod.log 中没有针对此错误的新日志。