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

  • Home
  • SEARCH
  • 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 6994631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:55:00+00:00 2026-05-27T19:55:00+00:00

Take this POJO as the domain. public class Invoice { private String codeNumber; private

  • 0

Take this POJO as the domain.

public class Invoice {
    private String codeNumber;
    private BigDecimal amount;
    private String notes;

    private List<InvoiceRows> rows;      
}

I have a form which takes that as @ModelAttribute.
The form has got four text inputs: codeNumber, amount, notes and “emailAddressToNotify”.
The POJO’s “rows” property is filled in another place, so it’s ignored and that’s right.

On the other side, the “emailAddressToNotify” property is sent by the form’s ‘POST’ but obviously it’s not related with the Invoice POJO. Actually, I need it in my controller “processForm()” method.

Can I simply add a @RequestParam parameter to get it?

And here’s the second part of the question, as it’s related to the first one:

in my web application, I will often write “huge” forms, in which the fields do not always correspond to the fields of one of my domain objects. So, I ask you for what is the best practice:

Do I have to write a “form-dedicated” POJO, so I can always use @ModelAttribute and validate fields the easy way?
or… ?

  • 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-05-27T19:55:01+00:00Added an answer on May 27, 2026 at 7:55 pm

    Can I simply add a @RequestParam parameter to get it?

    I think you’re asking if you can use both @RequestParam and POJO binding in the one controller method. Yes, this is possible. Maybe you should’ve just tried it rather than asking about it?

    Do I have to write a “form-dedicated” POJO, so I can always use @ModelAttribute and validate fields the easy way? or… ?

    This depends… You need to provide an example of what you’re doing for a useful answer. I.e. are you wanting to bind to multiple POJOs with one form, do the field names simply not match, do you have extra fields in the POJO you don’t want displayed, do the POJOs have heavily nested classes, etc…

    Its quite common to have a simple, flat bean/POJO to use as a “form-backing bean”. They’re often also called a DTO (data transfer objects). See What is Data Transfer Object?.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take this class as example: public class Category : PersistentObject<int> { public virtual string
Take this code: public class MyClass { private final Object _lock = new Object();
Take this sample code: Class Foo ReadOnly name As String Public Sub New(name As
Take this example model: public class Location { public string Id { get; set;
Take this non-compiling code for instance: public string GetPath(string basefolder, string[] extraFolders) { string
Take this sample class as an example: [AttributeUsage(AttributeTargets.All, AllowMultiple=true)] public class BugFixAttribute : System.Attribute
take this simple code: class A{ public: virtual void foo() = 0; void x(){
Take this class for an example: <?php class Person { private $name = null;
Take this class for example: public class Applicant : UniClass<Applicant> { [Key] public int
Take this class: package { import flash.display.MovieClip; public class test extends MovieClip { public

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.