Set button text to updated value when redirected from controller
<p>I have a button which has date value. When I click on button, a popup form will open. I will change the value and send the value to controller. In controller, after performing some operations, I am redirecting it to same page where my button is present. I am trying to set value sent from controller on button. But the value is not getting changed. I am using thymeleaf. here's my code.</p>

<p>This is my HTML code. Button and popup form. </p>

<pre><code>&lt;button id="appDate" th:value = "${date}"&gt;&lt;/button&gt;
&lt;div id="popupForm" style="display:none;"&gt;
    &lt;form th:action = "@{/getDate}" method="POST"&gt;
        &lt;input id = "text" type="text" name = "dateValue"  /&gt;
        &lt;input type="submit" value="Submit" /&gt;
    &lt;/form&gt;
&lt;/div&gt;
</code></pre>

<p>My jquery code to set button text in input on form.</p>

<pre><code>$(function () {
    now = new Date();
    $('#appDate').text(now);
});

$(function () {
    $("#popupForm").dialog({
        autoOpen: false
    });

    $("#appDate").click(function () {
        $("#text").prop('value', $("#appDate").text());
        $("#popupForm").dialog('open');
    });
});
</code></pre>

<p>My controller Code</p>

<pre><code>@RequestMapping(value = "/getDate",method = RequestMethod.POST)
public String getDate(@RequestParam("dateValue") String date,ModelAndView model)
{
    String input = date;
    // other functionality
    model.addObject("date",date);
    return "redirect:profile";
}
</code></pre>

<p>I want to access the date so that I can set it to button value. Can someone help me? Thanks :)</p>