Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8810157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:03:32+00:00 2026-06-14T03:03:32+00:00

in My jsp I am using spring form tags to bind and update data.

  • 0

in My jsp I am using spring form tags to bind and update data.

my scenario is to show default values when user enters the page. these default values should come from database depending on some conditions.
But when user edits the data and submit, I want to save them in databse without updating the default values.

Any suggestion is greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:03:34+00:00Added an answer on June 14, 2026 at 3:03 am

    Standard approach to a form page is to have a controller with two methods, one for GET and one for POST. You’ll also need an object to bind to the form.

    The method that handles the GET sets up the bind object and puts it in the model, then returns the view for the form page. The bind object here can be created with default values which you can get from anywhere. Your bind object will probably have some key, like an ID. The default one can have a zero/default key.

    The method that handles the POST takes the bind object as a parameter. It probably validates the values then inserts into the database. Its likely the database will generate the key/id.

    Here’s an example;

    @Controller
    public class PersonController {
    
      @RequestMapping(value="/person.do", method=RequestMethod.GET)
      public ModelAndView setup() {
        ModelAndView response = new ModelAndView("person");
    
        //Create default bind object, can get values
        //from database if you like. Here they're just
        //hard coded.
        Person person = new Person();
        person.setName("Joe Bloggs");
    
        response.addObject("person", person);
        return response;
      }
    
      @RequestMapping(value="/person.do", method=RequestMethod.POST)
      public ModelAndView post(@ModelAttribute("person") Person person,
                               BindingResult result) {
        Validator.validate(person, result);
        if (result.hasErrors()) {
          ModelAndView response = new ModelAndView("person");
          response.addObject("person", person);
          return response;
        } else {
          personDao.store(person);
        }
    
        return new ModelAndView("redirect:nextPage.do");
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSP that is using Spring:form tags to bind controls to a
Hi: In my jsp page,I have a form to add/update a nested object using
I am using spring security and have an admin jsp page for editing user
I'm trying to validate a simple form in JSP with Spring and Hibernate using
I'm using Spring Web Flow (v. 1.0.5) and I have a JSP page that
I'm using Eclipse/Spring source to edit JSP tags and EL. If I want to
I am facing issues with dynamically binding spring form elements in JSP using jquery.
I home some problems with encoding of data in JSP page (I'm using a
Using Javascript to add cells dynamically to a JSP page. Need to collect data
I am using JSPs, and this is my contacts.jsp <%@taglib uri=http://www.springframework.org/tags/form prefix=form %> <html>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.