java - Spring: Form is not getting redirected to given method in action url while submitting it -


i'm starting learn spring framework , in code i'm trying create empty form , checking whether getting redirected proper controller method. when specify javascript function in form submission action function getting executed when specify url can mapped controller method, controller method not getting called instead going mainpage of application. i'm not getting errors in log. please guide on this.

my view (.ftl):

<div class="form-page-header">   <h4 class="page-heading">first exercise</h4> </div> <form id="emptyform" class="form-horizontal" method="post" action="<@spring.url  "/user/create"/>">   <div class="panel panel-default">     <div class="panel-heading">       <b>user details</b>     </div>     <div class="panel-body">        <div class="col-sm-6 form-group">         <label class="col-sm-5 control-label">create new user</label>          <div class="col-sm-7">          </div>       </div>     </div>   </div>    <div class="form-group pull-left">     <input type="submit" class="btn btn-default" value="submit" />   </div>  </form> 

my controller:

usercontroller.java

@controller @requestmapping(value = "/user") public class servercontroller implements messagesourceaware {      private messagesource messages;     private userservice userservice;       @override     public void setmessagesource(messagesource messagesource) {         this.messages = messagesource;     }      @autowired     public void setuserservice(userservice userservice) {         this.userservice = userservice;     }      @requestmapping(value = "/", method = requestmethod.get)     public string list(modelmap modelmap) {         system.out.println("inside user controller");         return "user/view";     }      @requestmapping(value = "/create", method = requestmethod.post)     public modelandview create(modelmap modelmap) {         system.out.println("create server mapped...");         modelmap.addattribute("server", new user());         modelandview mnv = new modelandview();         mnv.setviewname("user/view");         return mnv;     } } 

now issue resolved. have security checks in application, had include csrf token in .ftl file , resolved issue.


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 -