I have a <form:form> in my jsp page with several <form:input> fields (so, fields are databound). Some of those fields are populated by user, but some, instead of waiting for user to enter some value, need to pre-populated with the value of parameter sent to this page from another jsp page, through the spring controller. How to write that parametar into <form:input> so user doesn't have to?
Pre-populated <form:input> field (spring-form.tld tag library)
2.2k Views Asked by just_a_girl At
1
There are 1 best solutions below
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in JSP
- Why we use double % in Java or JSP
- How to get specific values from select menu and use her in mysql query?
- How to compile an individual jsp file from command line
- How to keep a variable in the URL when using Spring LocaleChangeInterceptor
- How to pass value from input text to jsp variable?
- Importing a downloaded JAR file into a Servlet
- Upload PDF and display on same page
- Use javascript variables in JSP code
- How to add '%' symbol in textbox using jsf and jsp?
- Execute RequestDispatcher after 5 seconds
- Score book using javabean; how do I get overall average?
- Struts2 jqGrid DatePicker in Column Filter
- java.lang.StackOverflowError in spring controller
- Error on java application
- Requested Resource is not available error
Related Questions in SPRING-MVC
- Redirect inside java interceptor
- Custom Spring annotation for request parameters
- Spring - configure Jboss Intros for xml with java config?
- No mapping found for HTTP request with URI [/test/WEB-INF/jsp/hello.jsp] in DispatcherServlet with name 'HelloWeb'
- Show login dialog when not authenticated yet
- How to keep a variable in the URL when using Spring LocaleChangeInterceptor
- LightAdmin - Customise parsing DateTime with app timezone
- Spring + TestNG Autowiring failure - NOT due to "new"
- Spring Boot MVC non-role based security
- Pretty print JSON with Spring 4
- How to initialize @DateTimeFormat Parameter on Get?
- Spring security /j_spring_security_login 404 error
- Use thymeleaf template for some pages and rest for some for building gradle project
- java.lang.StackOverflowError in spring controller
- submit dropdown angularjs spring MVC
Related Questions in SPRING-FORM
- Collections Set form binding wont work in spring mvc?
- How to add, with Spring form, a new object to a List owned by the modelAttribute
- Spring is not showing validation error for Dynamically generated Form Id
- Don't refresh page after uploading a file using a spring form.
- How can I submit a form and upload a file using ajax to a spring controller?
- How to map dropdown from Spring form to one to many entities?
- Select Java Object from Spring Form drop down menu
- Spring form:input for number
- Add spring form checkbox selections to a collection and persist it
- How to bind set of enum values to form:select multiple="true" in Spring?
- Spring Form Validation (JSR-303)
- spring - http://www.springsource.org/tags/form 404 error
- How to handle data from form in Spring MVC
- Spring MVC update without redundant code?
- Prefill form:textarea spring mvc
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
If I understand your question correctly, you want to prepopulate some fields with values already submitted previously.
All you need to understand is that with the Spring form taglib, Spring expects you to put a command object in the model and will bind the values in that command object to the form fields.
If you don't specify the key for this command object in the model, the taglib will look for it with the key "command". You can specify a different name though with the commandName attribute on the form tag, such as:
Spring would now look for an object in the model named myModelObject to use to bind the form tags.
The other thing you then need to do is in the form tags in your Spring form, reference the fields in your command object. So, for example, let's say your command object has a field firstName, you'd have an input tag like this:
The path attribute tells the attribute what fields in the command object it should bind with.
So then you simply put the command object in your model with the appropriate fields prepopulated and the corresponding form fields will have those values prepopulated. Such as if you put an object in the model with the name myModelObject that has a field firstName, it will be prepopulated with whatever firstName is currently set to in that object.