Home Thymeleaf: How to make a button link to another html page?
Reply: 1

Thymeleaf: How to make a button link to another html page?

sndu
1#
sndu Published in 2017-09-14 10:02:03Z

I have an input button in my html page. I want to link the button to another html page with thymeleaf. This is my code.

<form id = "hotDealForm" th:action = "@{/hot-deal-step-1}">
<div class="col-xs-12 col-sm-6 col-md-6">
    This Hot deal
    <br/>
<input type="button" value="Continue to schedule" class="btn btn-red" />
</div>
</form>

My controller works fine. (I'm working with spring mvc). But I can't figure out what the problem is. I can do the same task using html. But when I am using thymeleaf its not working. That is when I clicked the button nothing happens.

Pashupati Khanal
2#
Pashupati Khanal Reply to 2017-09-14 10:45:21Z

Hi !

There are many ways you can do but what I find the easiest is give a button class to a link as in following example. Since this class is a bootstrap's class so you need to have reference to bootstrap. Since you are using MVC it already got Bootstrap linked.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

   
 <a href="@Url.Action("Index")" class="btn btn-success"> <i class="fa fa-arrow-circle-o-left"></i>&nbsp;Back to List</a>

Next You can do following:

@using (Html.BeginForm("Index", "Home", FormMethod.Post))

{

<input type="submit" value="Go To Dashboard" />

}

And in Index of Home You can do :

public ApplicationUserManager UserManager
    {
      return RedirectToAction("Index","Dashboard",new{area="Admin"})
    }
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301952 second(s) , Gzip On .

© 2016 Powered by cudou.com design MATCHINFO