dongrui6787 2016-08-06 15:48
浏览 27

我如何清除Symfony中的查询字符串

In a Symfony 3 application i've a route for the search form with two controllers: one for a head/get request, and one for a post request. I need two controllers as searches can be shared.

Here's my problem: if a user comes to the site from a link with a query string, but then performs a post of the search form ... the query string from the original link he clicked always remains in the url, even after page reload.

So the question is: how can i clear out the query string? I've tried to remove all keys in the query ParameterBag of the request (which seems far-fetched as a way to solve this), but that didn't work.

Here's the code in my controller:

    $form = $this->buildSearchForm();
    $form->handleRequest($request);
    $searchTerm = $form->get('search')->getData();
    $types = $this->getTypes($form);
    $query = $this->assembleQuery($form);

    return $this->render("search/zoekpagina.html.twig", array(
        "distance" => $form->get('distance')->getData(),
        "form" => $form->createView(),
        "results" => $ESquery->searchByType($types, $query, $searchTerm),
        "searchTerm" => $searchTerm,
        "filters" => true,
    ));
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 我的数据无法存进链表里
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端