Christine Jang
Christine Jang

Reputation: 1

400 bad request when submitting form

I can't seem to figure out why I keep getting a 400 bad request. Before I got 400 bad request, the form had "id" instead of "name". When the form had "id" I got 200 but didn't update my database. Now, I get the error and nothing seems to be working.

Here's my controller:

@RequestMapping(value = "/registration", method = RequestMethod.POST)
public String registration(MemberVO vo, Model model) {
    System.out.println(vo);
   logger.info("regist post...");
   logger.info(vo.toString());

   try {

    mservice.insertMember(vo);


   } catch (Exception e) {

    e.printStackTrace();
   }
      return "/register_success";
}

@RequestMapping(value = "/registration", method = RequestMethod.GET)
public void registrationGet(MemberVO vo, Model model) {


}

Here's my form:

  <form role = "form" method ="post">        

    <div class="form-group">
         <input type="email" class="form-control" name = "username" placeholder="Email"  required/>
         <span><i class="fa fa-envelope"></i></span>
    </div>

    <div class="form-group">
         <input type="password" class="form-control" name = "password" placeholder="Password"  required/>
         <span><i class="fa fa-lock"></i></span>
    </div>

    <div class="form-group">
         <input type="text" class="form-control" name = "firstname" placeholder="firstname"  required/>
         <span><i class="fa fa-user"></i></span>
    </div>

     <div class="form-group">
         <input type="text" class="form-control" name = "lastname" placeholder="lastname"  required/>
         <span><i class="fa fa-user"></i></span>
    </div>

    <div class="form-group">
         <input type="text" class="form-control" name = "phonenum" placeholder="Phone Number"  required/>
         <span><i class="fa fa-user"></i></span>
    </div>                                    

    <div class="form-group">
         <input type="text" class="form-control" name = "birthday" placeholder="Birthday, ex) 1986-06-08"  required/>
         <span><i class="fa fa-user"></i></span>
    </div>

    <div class="form-group">
         <input type="text" class="form-control" name = "destination" placeholder="where would you like to go?" required/>
         <span><i class="fa fa-user"></i></span>
    </div>

    <button type = "submit" class="btn btn-orange btn-block">Sign Up</button>
  </form>

Upvotes: 0

Views: 134

Answers (1)

Alien
Alien

Reputation: 15878

We can not tell you the exact problem as you have not attached your modal class MemberVO but you can check below.

1.There is no action attribute in your form.

2.Ensure that all the fields present in Modal class should also be present in the form with the same name.

Upvotes: 1

Related Questions