I know this is going to be really simple but I can't figure out how do get a path variable from a form.
This is my form defined below:
<form:form action="dogs/" method="get">
<div class="row">
<div class="col-md-3">
<div class="input-group">
<div class="input-group-addon" style="background-color: transparent; border-right:0 solid transparent;"><span class="glyphicon glyphicon-search"></span></div>
<input type="text" class="form-control" placeholder="search by ID #" name="id" id="id" />
<div class="input-group-btn">
<input type="submit" class="btn btn-info" value="Go" />
<button class="btn btn-info" onclick="location.href='id'">Go</button>
</div>
</div>
</div>
<br><br>
</div>
</form:form>
And this is my controller method, where I am suppose to get the path variable:
@RequestMapping(value ="dogs/{id}", method = RequestMethod.GET)
public String getDogId(@PathVariable(value ="id") Long value, Model model){
return "";
}
But the url I get and also causes an error is the following:
http://localhost:8080/controller/dogs/dogs/?id=8
what I want is: http://localhost:8080/controller/dogs/8 I don't know how to pass the input dynamically to the button or not even to the button but to the form action. Any help would be greatly appreciated.