java - How to define path variable to pass to controller (spring mvc) -


i know going simple can't figure out how path variable form.

this 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 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 controller method, suppose path variable:

@requestmapping(value ="dogs/{id}", method = requestmethod.get) public string getdogid(@pathvariable(value ="id") long value, model model){         return "";  } 

but url , causes error following:

http://localhost:8080/controller/dogs/dogs/?id=8

what want is: http://localhost:8080/controller/dogs/8 don't know how pass input dynamically button or not button form action. appreciated.

i'm afraid cannot accomplish without of javascript.

edit: here jsfiddle that: https://jsfiddle.net/n588jl07/2/

function seturl(form) {     form.action="dogs/"+form.urlval.value;     console.log(form.action);     event.preventdefault(); } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -