Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


how to update user details by jsp form in spring security java config using -'hibernate,jsp,spring-security,spring-java-config'


how to update user details by jsp form in spring security java config  using -'hibernate,jsp,spring-security,spring-java-config'

I'm trying to edit and update the information of user like username,phone number,address and emailId in spring security hibernate. I'm editing the information in a form and trying to update by submitting the form.I'm new to spring security, so can you help me to submit the updated form and save?

AppController.java

@RequestMapping(value={"/update"}, method = RequestMethod.POST)
    public String update(@Valid User user,BindingResult result,ModelMap model){
        service.updateUser(user);
        return "prefs";
    }


AppDao.java

void updateUser(User user);


AppDaoImpl.java

@Override
public void updateUser(User user) {
    Session session = getSession();
    session.saveOrUpdate(user);
    session.update(user);
}


prefs.jsp

   <form method="POST" name="editProfile" action="update">
    <div class="margin-top-10  form-group">
      <input class="form-control input-lg" name="name" id="name" placeholder="Contact Name" size="25" type="text" value="${user.getName()}">
      <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
    </div>
    <div class="margin-top-10  form-group">
      <input class="form-control input-lg" name="contactNumber" id="contactNumber" placeholder="Phone Number" size="25" type="text" value="${user.getContactNumber()}">
    </div>
    <div class="margin-top-10  form-group">
      <input class="form-control input-lg" name="emailId" id="emailId" placeholder="Email" size="25" type="text" value="${user.getEmailId()}">
    </div>
    <div class="margin-top-10  form-group">
     <input class="form-control input-lg" name="address" id="address" placeholder="Address" type="text" value="${user.getAddress()}">
    </div>
    <div class="margin-top-10  form-group">
      <input class="form-control input-lg" name="password" id="password" placeholder="Password" size="25" type="hidden" value="${user.getPassword()}">
    </div>
    <div class="margin-top-10 form-actions form-group">
      <button type="submit" class="btn btn-default btn-primary" id="updateUser">Update Settings</button>
     </div>
   </form>

    

asked Sep 7, 2015 by rajesh
0 votes
19 views



Related Hot Questions



Government Jobs Opening


...