form 1 « MVC « Spring Q&A

1. Best Practice for Spring MVC form-backing object tree initialization

If I have a form-backing object that has a complicated object tree -- say a Person that has a Contact Info object that has an Address object that has a bunch ...

2. Simple autosave for Spring MVC form

I have one page form done with Spring MVC. User has to register first and I would like the form to be saved automatically so user can come later to finalize ...

3. Can a Spring form command be a Map?

Can a Spring form command be a Map? I made my command a Map by extending HashMap and referenced the properties using the ['property'] notation but it didn't work. Command:

public class MyCommand ...

4. Spring MVC - Form Mapping

Probably missing something completely obvious here, but here goes. I'm starting out with Spring MVC. I have a form controller to process inbound requests to /share/edit.html. When I ...

5. better way for dynamic forms with Spring?

What I wonder is if there's a easier/better way to handle dynamic forms (adding form items to the dom via js) when using SpringMVC and Spring forms? Imaging having an Invoice object ...

6. Spring MVC form input value is always null

I'm new to Spring MVC, but not new to web development in Java. I'm attempting to create a simple form->controller example. I have a form, a form controller (configured in a ...

7. Dynamic Forms in Spring

I am trying to make a dynamic form using Spring forms. Basically, the form gets a title of learning activity and then there's the a button below it that says, "Add ...

8. How to set up a global prefix and suffix used in each error field in Spring?

In Struts, you can confire a global prefix and suffix in a resource bundle file. Something like:

errors.prefix=<div class="error">
So <div class="error"> will be added before each <html:errors and </div> will be added ...

9. How should I handle having one identical form on many pages in Spring MVC

Title says it all really. I have a login form that has some validation on many pages in my website. How best do I structure my controllers to avoid repeating the ...

10. multi-staged form using spring

please forgive me for this stupid questions. I just started developing web application using spring yesterday. The project that i worked on, have a multi staged form, that require users to complete ...

11. Spring file upload in a mixed form

I want to upload a file to my spring 3.0 applicatoin (created with roo). I already have the following entity:

public class SelniumFile {

    @ManyToOne(targetEntity = ShowCase.class)

12. Java - Spring MVC - Automatically populate object from form submission?

In ASP.NET MVC in the controller I can just have an object from my model be a parameter in one of my methods, and a form submission that gets handled by ...

13. A page with some input boxes posts to a action, what are my options in retrieving form values?

I have a controller that a form posts to:

 @RequestMapping(value = "/formtest", method = RequestMethod.POST)
    public ModelAndView HandleFormPost()

14. Duplicate form submission in Spring

What's the best way of avoiding duplicate form submission in Spring. Does this framework provide any special feature to handle this problem (for example as tokens in Struts)? Thanks.

15. Spring MVC 3: How do I construct a form action restfully?

Given some typical search form, I can't construct this form action when submitting a form:

Because the user is typing in orderId, so I can't include it in the form action.
  1. Is there ...

16. Spring MVC manual form elements

How would explicit hidden input elements be bound a model attribute? I'm not using <spring:bind> or <form:hidden>. I have a Form bean that has an object with a child collection. ...

17. Multi Action with Form design streatgy

I want to have a controller that can handle multiple requests. Like a UserController handling all the addUser, deleteUser, updateUser and viewUser functionality. I know that MultiActionController can be used to ...

18. How to handle MaxUploadSizeExceededException

MaxUploadSizeExceededException exception appears when I upload a file whose size exceeds the maximum allowed. I want to show an error message when this exception appears (like a validation error message). How ...

19. spring add default value to form:select

I'm developing a spring application, now I've added a dropdownlist to one of my jsp pages using:

<form:select multiple="single" path="users[y.count-1].X" items="${Y}" itemValue="id" itemLabel="name"/>
Now I'd like to add the default value "Nothing selected", ...

20. Creating multiple forms in one jsp file. ModelAttributes have to always be set?

I am new to Spring and have been reading about it the last few days. I haven't found an open source example like this so far and didn't see a clear ...

21. spring-form.tld...where is it?

I cannot find this tag lib, i need it because does not work.

22. Having Multiple forms on spring MVC

I have this question about Spring MVC 2.5. Oftentimes, I am only using one form in all my JSP. Now I need to add another form into the same JSP. My question ...

23. Spring form:option

Is there any way to mark an option as selected by default, much like the selected attribute in the HTML option tag like <option value="value1" selected>?

24. spring mvc form textarea initial contents

How do I put initial text into a Spring form textarea? The TLD rejects PCData content inside form:textarea. The point of this form is to ask a user to edit/correct some ...

25. Spring MVC one form feeding data to another form

My starting problem is this error message:

Problem accessing /segment.htm. Reason:
Neither BindingResult nor plain target object for bean name
'acceptCorrected' available as request attribute
The top-level ...

26. Default value of form object's field

I have a form where depending on the select state ([checkboxOn/checkboxOff]) a check box should appear or not. When the check box is displayed it should be checked by default. How to ...

27. Spring 3 binds empty form

On a view I have 1 form and 1 list with form - both are within single tag. List is bound to ArrayList of beans and related form is used ...

28. Spring MVC form:errors not showing up

Apologies if this question has been asked before. I'm hoping that someone can step in and help me figure out why my form validation errors aren't showing up. I'm using Spring 3.0.3 ...

30. Adding HTML5 placeholder attribute to spring 3.0 form input elements

How do I add HTML5 placeholder attributes to Spring webmvc's form:input, form:password and form:textarea elements?

31. Give a different value to form input

I am currently working on a Spring project and I need some help. In my JSPs pages I am using spring form tags. For example:

<form:input size="30" type="file" path="attachment" />
I need to ...

32. In Spring-mvc the attribute names in view have to always match the property names in model?

In the http request body, the way password string is passed is "pass=1111", however in the bean the way password is defined is ''private String password". Is there a way I ...

33. Dynamic Form in Spring 3

I have custom Question objects which I render into html form elements. I want to be able to dynamically create these objects and generate a dynamic html form from them. The ...

34. How to print Global errors only with form:errors?

In my form, i have some specific targeted errors (with path="myField") and i'd like to throw global errors, because they span multiple fields. But if i use <form:errors path="*">, it will print ...

35. Spring MVC 2.5 form backing object using @modelAttribute

@RequestMapping(method = RequestMethod.GET)
public String setupForm(@RequestParam("username") String username, ModelMap model, HttpServletRequest request) {
    User userFromDB = userService.getUser(username);
    UserPersonalDetails userDetails = userService.getUserPersonalDetails(username);
    UserBackingObject user ...

36. spring file uploading in complex folrm

We are moving to Spring MVC and stucked with froms... Is it possible to upload file with spring if the form is complex? I mean I have a few text fields(such ...

37. WizardForm in Spring 3

I found a code from Spring forums that seems to be an interesting way to implement wizardForms in Spring 3:

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processSubmit(
@ModelAttribute("pet") Pet pet,
SessionStatus status) {

38. Spring form and existing objects

I have a problem with Spring forms. Let's explain:

  1. if I want to create a new object out of a form, the contents of the form will fill the bean as expected. If I re-send ...

39. Losing modelattribute between methods

This controller works as it should

public class GiveFormController {

    private PersonDao personManager;
    private KeyCardManager database;
    private GiveFormValidator validator;

    public ...

40. Domain Transfer Object for a html form with various count of fields

has anybody dealt with a situation, that on the client side (html form) there is one type of field, that exist various times ? like

    <input id="fileRef1" ...

41. Java / Spring model forms framework

Is there any model/entity form abstraction library available i can use in Spring projects ? I'm looking something like "Django forms framework" or "Symfony Forms" in the Java/Spring ...

42. Spring form submission and successView problem?

(A silly question?)In springframework, the simpleFormController interface has a property called successView, but I am wondering how can I pass the submitted form information to this successView? The official tutorial has this:

return ...

43. With Fields and File uploading

I have a form which contains fields and file upload elements while submitting the form it is throwing a null pointer exception, when i logged the form object all fields are ...

44. How to show List as table in spring mvc form

public class Parent {

    private Integer Id;
    private String  name;
       private String age;

    private List<Childrens> ...

45. How to pass a hidden value in a form in Spring MVC 3.0?

How to pass a hidden value in a form in Spring MVC 3.0 I am not able to assign a value to a hidden field using <form:hidden path="test" />. How can I ...

46. good pratice for mvc, form data

i would like to know if there are some web site who list good pratice for spring? i started a program, i splitted it with a controller, service and dao layer but ...

47. spring MVC : form : radiobutton for Boolean property

I just want to know how to use a Boolean in a Spring mvc form. I try with this code: My jsp:

<form:radiobutton path="dateInterval" value="false" cssClass="radio"/>
<form:radiobutton path="dateInterval" value="true" cssClass="radio"/>
The property on the pojo:
private Boolean ...

48. Spring mvc form pre-filled : list with preferences

I have data in database for user's languages preferences. I want to manage thoses informations in the front-end of a web application with Spring MVC. I retrieve preferences by service and ...

49. Fill the fields of a form automatically after a field is filled using springs and jsp

I have a form that lets the user to either add an employee's details or edit existing details. Once the user enters the employee id in the form and presses search ...

50. some form fields are cleared on bindAndValidate() after formbackingobject() populate them correctly, Spring MVC

I m working on some existing code where the controller overrides the formbackingobject method. the object returned from the formbackingobject is populated correctly, but when it reaches the jsp some fields ...

51. Using StringTemplate together with forms in SpringMVC

does anyone know how to use StringTemplate with forms in SpringMVC framework? Any tips, tutorials...?

52. How can I populate command object from form populated client-side?

My system needs to process purchase-orders (PO, PurchaseOrder class), where a PO is comprised of 1..n LineItem's. Users add line-items which comprise a number of columns, some are drop-down selects, some ...

53. Object properties editing with Spring Forms

I'm a bit confused about how an object could be edited with Spring Forms, for instance: suppose I have an object Person who has a lot of attributes because I obtain ...

54. Dynamic list item index with Spring Form

For decorated unordered lists like this:

private List<MyListItem> items = LazyList.decorate(new ArrayList(),
Is it compulsory to name the attributes in the form with an index ...

55. Spring MVC form:errors using Ajax

I have a question related to Spring 3 MVC, Ajax, and form:errors. I have a form I am submitting to the server and I am using Spring MVC. I have all ...

56. Springs 3, forms?? how do select optin in dropdown (select box)?

I am writing a system in Springs 3 and everyone works great on the inbox screens but on one of the input screens I have a dropdown box or a selectbox. ...

57. Creating editpage with Spring

I would like to create a page where user can edit form values before sending. I have this method in my Spring 3 application

@RequestMapping(method = RequestMethod.POST, params = {"back"})
public String back(@ModelAttribute("opForm") ...

58. Spring form errors custom html

I need to do something like that:

 <form:errors path="*">
        <div class="error">

59. Linked select lists in Spring 3

My task is to populate another select list based on what is choosen from one select list, querying populating data from database. I think it goes something like:

  1. User clicks the parent selectlist ...

60. A block that only shows non-field errors?

Is it possible to configure a <form:errors/> element that only shows non field errors? I've tried the following, but of course it lists all errors both field and non-field.

<resource:hasBindErrors name="dualEntryForm">

61. Getting form object values in a script

If you have this kind of form attribute in Spring:

<form:select path="" items="${objects}" itemValue="id" itemLabel="description">
How can you pass the id (type is int) value to script?
this.val returns nothing. I need to ...

62. Linked selectlists in Spring 3 spring form part

I have one further question related to earlier post: Linked select lists in Spring 3 How the subcategory select list must be written in Spring jsp page?

63. How to specify default value for form input using Spring and Freemarker

I am using Spring MVC and Freemarker. I have created a form and I want to put a default value into a formInput

<@spring.formInput 'search.value' ''/>
But the documentation is a bit weak and ...

64. What is the full form of SPI in Spring 3 type conversion system?

Sorry for this stupid question, but I want to know the full-form of SPI in Spring 3 type conversion API :-(

65. Spring: form and results on same page, how to display results on first view

I'm doing some volunteer work for the local school district and am trying to come up to speed with Spring 2.5. We have a scenario where we would like to ...

66. Spring MVC form example without JSP

Can a Spring MVC form example work without any JSP files? I am working on a project which is using htm templates and i wish to use Spring MVC forms in ...

67. Spring MVC form:select selected value?

Is there any way to select current value in dropdown list by Spring MVC by "< form:options>" ?

68. Spring MVC Form

How do I make a value retrieved from a form object available to another class. Lets call this class How do I make the values submitted from the JSP form available ...

69. Spring MVC form:select does not work

I really need help on form:select Here’s the deal: Whenever I use this in my JSP:

<form:select delimiter="<br>" path="**offer.offerId**" items="${offerList}" itemValue="offerId" itemLabel="offerName" />
I get this error:
org.springframework.beans.NullValueInNestedPathException: Invalid property 'offer' of bean class []: ...

70. Spring MVC default value?

Is there any way to select default value in dropdown list by Spring MVC by "< form:options>" ? I mean: If an option's id is equal to my model attribute Id, I ...

71. Spring MVC selected value

I got relation "Many to one" between my CPVCode adn OrderType:

public class CPVCode {

    private int id;

72. SpringMVC : Form processing for a survey application

In my Spring 3 MVC webapp, I need to be able to access all the submitted form fields. Normally, I know what forms fields exist in the form and process the submitted ...

73. Simple form to edit model in Spring MVC

What is the best way to change data of, for example, User? I got lots of properties like 'username', 'city', 'phone' and when I want to edit just one field ('password'), I ...

74. Spring form, create elements client side usig javascript

I have a spring form, with backing object that includes a LazyList - works hunky dory. The form initally shows:

<form:textarea path="myList[0]" cssClass="myClass" rows="2" cols="35"/>
<form:textarea path="myList[1]" cssClass="myClass" rows="2" cols="35"/>
When a user focusses ...

75. Spring MVC 3: open ModelAndView in a new tab

I am submitting a form in jsp. After running the underlying logic spring mvc returns view. There are 2 conditions. i.e.

    mav = new ModelAndView("jspPageName1");

76. Spring @ModelAttribute doesn't care about commandName


<form:form commandName="editWeather" method="post" action="../edit">
    <!-- Input fields -->
    <input type="submit" value="Submit">
And this is how I get the model in Spring:
@ModelAttribute("DONTGIVEADAMN") Weather weather
And I can still ...

77. Spring MVC : Table of forms?

I am trying to build something with Spring MVC and I'm not sure how to approach it. I'm hoping for some advice and hopefully some solutions. I need to display a table ...

78. Pattern for handling exceptions in form submission of spring mvc

I am working on a legacy project, converting it to annotation based MVC. I am noticing alot of times in the onsubmit method where the following pattern is followed:

public ModelAndView ...

79. Need assistance getting a Spring form to work

I'm in the middle of writing a Spring webapp and things were going well. I'm trying to write a form that allows an admin to change some basic user details. However, ...

80. Spring 3.0 forms dynamic elements

I'm working on a dynamic form using spring 3.0. The form I'm building generates a list of text entries, from a database, and has checkboxes associated with each text entry. The ...

81. Function calls messing with each other

I have following code in my popup jsp:    

<input type="submit" value="Mod" onclick="remind()" ></input> &nbsp;
<input type="hidden" value="Mod" name="db_remind" id ="remindbutton"></input> &nbsp;
<input type="submit" value="Delete"  onclick="confirmDelete()" > </input>
<input ...

82. Getting "NotReadablePropertyException" on the incorrect form backing object

I'm using Spring 3.0.5 with Freemarker and I would like to return a different view from a controller. Let me explain the situation with code: I have a method that returns the model ...

83. Dynamic Forms creation in Spring

i want to create jsp dynamically, based on the number of fields on that jsp using spring framework. and the number of fields that would be rendered on the jsp will be ...

84. Spring 3 MVC: how to create the form-backing object at form submission?

I read a few tutorials about forms and submission in Spring 3 MVC. All these examples store the form backing object in the session the following way:

What I would like to ...

85. How to change the package name in " Spring 3 MVC Login Form Example" in

I am new to the spring framework, and I just followed the "Spring 3 MVC Login Form Example" in And first time I changed package name:net.roseindia.controllers to ...

86. What is the right way to handle form variable

SpringMVC provides powerful annotation to handle JSP form data by passing data into a form bean (or POJO) whose fields are match up with the variables in the JSP form. I ...

87. How to hold fields form than are not in the model object ?

How to hold fields form than are not in the model object ? Hi, My model object is store in the session by the "formBackingObject" function. In my jsp page i ...

88. Spring 3 MVC Forms

Spring 3 MVC Forms Hello Looking for some help with using Spring 3 MVC as I'm wrting my first project using it. Am trying to get my head around how form ...

89. Look Mom: Sexy Web MVC Forms

90. spring 3 mvc help with multiple forms on one page

spring 3 mvc help with multiple forms on one page Hi, I am new to spring 3 mvc using annotations. Have a jsp view page with 2 forms one for login ...

91. Boolean value in SpringMVC form

Boolean value in SpringMVC form I have a boolean attribute in one of my classes that appears web form as a radio group. I'm using MySQL as the database so the ...

92. Question regarding the Form Model

Question regarding the Form Model Hello, I have a question regarding the NestingFormModel/SwingFromModel. What I need to do is to edit an object in a main form, which has a subform ...

93. @ModelAttribute + form, questions

@ModelAttribute + form, questions Hi, I need to understand the function of @ModelAttribute annotation, but it's quite difficult for me. I have a form where the user can enter address + ...

94. Loosing values of a model in a form

Loosing values of a model in a form Hello everybody, i am very new to Spring and may be it is very simple, but after dealing with my controller for days ...

95. good pratice with mvc and form data

good pratice with mvc and form data hi i would like to know if there are some web site who list good pratice for spring? i started a program, i splitted ...

96. How to do a Wizard or a multi pages Form into Spring 3 MVC ?

I need to create a web wizard form (multipage form). I use Spring 3 MVC and I will manage two Entity. How do I do?

97. Unable to display of search results on the form page using Spring MVC

Unable to display of search results on the form page using Spring MVC Hi Everyone, I am new to Spring MVC. I am trying to use SimpleFormController class in order to ...

98. Question on Spring MVC Form Handling

Question on Spring MVC Form Handling Hi All, I am using Spring MVC, in my presentation tier. I am constructing a Payment form ( which includes the information which is taken ...

99. calling Ajax from onClick event of Spring MVC

Hi, Can someone provide an example of calling ajax function, on click event of a spring mvc field? Most of the examples available are for form submission. I want to ...

100. MVC, Error while Using a list of NameValue Objects when submiting a form

private List userNames; public List getUserNames() { return userNames; } public void setUserNames(List userNames) { this.userNames = userNames; }