Thymeleaf equivalent of c:url
<p>I'm trying to get a thymeleaf button to go to an mvc controller when clicked similar to how the c url work</p>

<pre><code>&lt;td&gt;&lt;a  class="btn btn-success" href="&lt;c:url value="/displayWikis" /&gt;"&gt;&amp;nbsp;&amp;nbspShow Wiki List&amp;nbsp;&amp;nbsp&lt;/a&gt;&lt;/td&gt;
</code></pre>

<p>currently my code is as follows in my thymeleaf page</p>

<pre><code>&lt;td&gt;&lt;button type="button"  th:href="@{/getAll}"&gt;Get All Post &lt;/button&gt;&lt;/td&gt;
</code></pre>

<p>This is the thymelead page</p>

<pre><code>    &lt;!DOCTYPE html&gt;
&lt;html xmlns:th="http://www.thymeleaf.org"&gt;
&lt;head lang="en"&gt;


&lt;title&gt;MVC Home&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;

&lt;link href="../static/css/bootstrap.css" th:href="@{css/bootstrap.css}"
rel="stylesheet" media="screen" /&gt;

link href="../static/css/bootstrap-theme.css"
th:href="@{css/bootstrap-theme.css}" rel="stylesheet" media="screen" /&gt;


&lt;script type="text/javascript" src="../static/js/jquery-2.2.2.js"
th:src="@{js/jquery-2.2.2.js}"&gt;&lt;/script&gt;


&lt;script type="text/javascript" src="../static/js/tether.js"
th:src="@{js/tether.js}"&gt;&lt;/script&gt;



&lt;script type="text/javascript" src="../static/js/bootstrap.js"
th:src="@{js/bootstrap.js}"&gt;&lt;/script&gt;


&lt;/head&gt;
&lt;body&gt;


&lt;div class="container"&gt;
    &lt;div class="jumbotron"&gt;

        &lt;h1&gt;Form&lt;/h1&gt;
        &lt;form action="#" th:action="@{/mvchome}" th:object="${post}"
            method="post"&gt;

            &lt;table&gt;

                &lt;tr&gt;
                    &lt;td&gt;Username:&lt;/td&gt;
                    &lt;td&gt;&lt;input type="text" th:field="*{userAcctName}" /&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td&gt;City:&lt;/td&gt;
                    &lt;td&gt;&lt;input type="text" th:field="*{city}" /&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td&gt;Content:&lt;/td&gt;
                    &lt;td&gt;&lt;input type="text" th:field="*{content}" /&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td&gt;&lt;button type="submit" name="action" value="save"&gt;Submit post&lt;/button&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;button type="button"  th:href="@{/getAll}"&gt;Get All Post &lt;/button&gt;&lt;/td&gt;

                &lt;/tr&gt;


            &lt;/table&gt;


        &lt;/form&gt;



    &lt;/div&gt;
    &lt;div&gt;
    &lt;!--        &lt;button type="button" th:href="@{/getAll}"&gt; Get All &lt;/button&gt; --&gt;
    &lt;/div&gt;

    &lt;!--  Results Block --&gt;

    &lt;th:block th:each="post : ${postsList}"&gt;


        &lt;div class="card "&gt;
            &lt;div class="card-block"&gt;
                &lt;h4 class="card-title" id="test" th:text="${post.subject}"&gt;Subject&lt;/h4&gt;
                &lt;h6 class="card-subtitle text-muted" th:text="${post.created}"&gt;Date
                    Created&lt;/h6&gt;
            &lt;/div&gt;

            &lt;div class="card-block"&gt;
                &lt;p class="card-text" th:text="${post.content}"&gt;Post Data&lt;/p&gt;
                &lt;a href="#" class="card-link"&gt;&lt;/a&gt;
                &lt;button type="button" class="btn btn-sm btn-danger"
                    data-toggle="popover" title="Popover title"
                    data-content="th:text='${post.city}'"&gt;See Popover&lt;/button&gt;
            &lt;/div&gt;
            &lt;div class="card-footer text-muted" th:text="${post.temperature}"&gt;&lt;/div&gt;
        &lt;/div&gt;

    &lt;/th:block&gt;



&lt;/div&gt;

&lt;script&gt;
    function getAllByUser() {

        $.ajax({
            type : "get",
            url : "https://localhost:8443/api/getAllForUser",
            cache : false,
            data : 'user=' + $("#userAcctName").val(),
            success : function(response) {
                alert(response);

                //some how pass this response data to ${postsList}

                $('#test').html("" + response[0].subject);

                $(".card").children().removeClass('hidden');
                $('[data-toggle="popover"]').popover();
            },
            error : function() {
                alert('Error while request..');
            }
        });
    }

    $(document).ready(function() {
        $('[data-toggle="popover"]').popover();
        //          $(".bg-success").children().addClass('hidden');

    });
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Here's the controller code</p>

<pre><code>@Controller
public class PostController {

private final PostService postService;

@Inject
public PostController(final PostService postService){
    this.postService=postService;
}



@RequestMapping(value="/", method = RequestMethod.GET)
public String home() {
    return "home";
}


@RequestMapping(value="/mvchome", method = RequestMethod.GET)
public String mvchome(Model model) {
    Post post = new Post();

    model.addAttribute("post", post);
    return "mvchome";
}



@RequestMapping(value = "/mvchome", method=RequestMethod.POST)
//public String create(@Valid Post post, BindingResult bindingResult, Model model) {
public ModelAndView create(@Valid Post post) {
//      if (bindingResult.hasErrors()) {
//          return "mvchome";
//      }
    //Post post = new Post(0, 1, 0, content,content, new Date(),userAcctName,city, null, null, null);
    post.setParentId(0);
    post.setDisplayOrder(1);
    post.setIndentLevel(0);
    post.setSubject(post.getContent());
    post.setCreated(new Date());
    post.setLatitude(null);
    post.setLongtitude(null);
    post.setTemperature(null);
    postService.savePost(post);
    ModelAndView mav = new ModelAndView("mvchome");

    mav.addObject("postsList", post);
    Post newpost = new Post();

    mav.addObject("post", newpost);
    return mav;

}


@RequestMapping(value = "/getAll")
//public String create(@Valid Post post, BindingResult bindingResult, Model model) {
public ModelAndView getAll() {
//      if (bindingResult.hasErrors()) {
//          return "mvchome";
//      }

    List&lt;Post&gt; postList=postService.findAllPosts();
    ModelAndView mav = new ModelAndView("mvchome");
    mav.addObject("postsList", postList);
    return mav;

}

}
</code></pre>

<p>I've searched around and so far I can't find a similar functionality.
Can any one point me in the right direction?</p>

<p>Thanks      </p>

<p>****Followed as suggested however now I'm getting this error</p>

<pre><code>    23:50:25.592 [http-nio-8443-exec-10] ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][http-nio-8443-exec-10] Exception processing template "mvchome": Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (mvchome:44)
23:50:25.593 [http-nio-8443-exec-10] ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (mvchome:44)] with root cause
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'post' available as request attribute
at org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:144) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
</code></pre>