spring - HTTP Status 400 - Required Integer parameter 'id' is not present -


i have problem when build spring + spring mvc + hibernate + mysql project.

everything works fine when "editpage" , want post editing information mysql, following error tomcat:

http status 400 - required integer parameter 'id' not present 

controller class

@requestmapping(value = "/users/edit", method = requestmethod.post) public string saveedit(@modelattribute("userattribute") user user,                        @requestparam(value = "id", required =    true)integer id, model model){      logger.debug("received request update person");      user.setid(id);      personservice.edit(user);      model.addattribute("id", id);      return "editedpage"; } 

service class

public void edit(user user){      logger.debug("editing existing user");      session session = sessionfactory.getcurrentsession();      user existinguser = (user) session.get(user.class, user.getid());      existinguser.setlogin(user.getlogin());     existinguser.setpassword(user.getpassword());     existinguser.setreal_name(user.getreal_name());      session.save(existinguser); } 

my jsp page

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <%@ page language="java" contenttype="text/html; charset=utf-8"      pageencoding="utf-8"%> <!doctype html> <html lang="en">  <head> <!-- bootstrap core css --> <link href="<c:url value="/resources/styles/bootstrap.min.css" />"         rel="stylesheet"> <script src="<c:url value="../../resources/javascripts   /non-empty_validation_editpage.js"/>"></script>  <title>editing page</title>  </head>  <body>  <h1 style="text-align: center">edit page</h1>  <c:url var="saveurl" value="/main/users/edit?id = ${userattribute.id}"/> <form:form modelattribute = "userattribute" method = "post" action =   "${saveurl}">  <div style="width: 300px; height: 500px; margin: auto;">  <div class="form-group" > <form:label path = "id">id:</form:label> <form:input type = "id" name = "id" path = "id" disabled="true"   class="form-control" />  </div>  <div class="form-group">   <form:label path = "login">login</form:label>   <form:input type = "login" name = "login" path = "login" class="form-  control"  placeholder="new login"/>  </div>  <div class="form-group"> <form:label path = "password">password</form:label> <form:input type = "password" name = "password" path = "password"  class="form-control"  placeholder="new password"/>  </div>  <div class="form-group"> <form:label path = "real_name">real name</form:label> <form:input type = "real_name" name = "real_name" path = "real_name"  class = "form-control"  placeholder = "new real name"/>  </div>  <input type="submit" class="btn btn-success" value="save"  style="width:   300px"/>  </div>  </form:form>  </body> </html> 

this comes when information required in method[@requestparam(value = "id", required =
true)integer id] in case id not present request parameter whenever u posting saved data. trying hard coding number instead of @requestparam(value = "id", required =
true)integer id, should able save data. way changed required = true false testing purposes , see if makes difference


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -