0

I have some example controller with method which return home page as follow:

public class IndexController {
    @RequestMapping(value="/", method=RequestMethod.GET)
    public ModelAndView mainPage() {
        return new ModelAndView("home");
    }   
}

In every page off my application I would like to have a link (on top or bottom of page- nevermind), which will point to my homepage controller method.

How can i construct this in thymeleaf?

  • Is there some ready to use soultion that work out of the box?
  • Or should I implement my own routing mechanism?
masterdany88
  • 5,041
  • 11
  • 58
  • 132
  • possible duplicate of [Playframework2 like reverse routing in spring](http://stackoverflow.com/questions/27080454/playframework2-like-reverse-routing-in-spring) – Brian Clozel Nov 23 '14 at 15:44

1 Answers1

0

Something like this?

<li><a th:href="@{/}">Home</a></li>

This is how you can construct it.

If you want to have it on every page, you should create fragment, put this into it, and then just add fragment to any page you want.

Djordje Ivanovic
  • 4,151
  • 4
  • 27
  • 49