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.
Request parameters can be easily accessed in Thymeleaf views. Request parameters are passed from the client to server like: https://example.com/query?q=Thymeleaf+Is+Great! In the above example if parameter q is not present, empty string will be displayed in the above paragraph otherwise the value of q will be shown.
There are three basic ways to include content from a fragment: insert – inserts content inside the tag. replace – replaces the current tag with the tag defining the fragment. include – this is deprecated but it may still appear in a legacy code.
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> 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"})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With