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 8122359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:48:46+00:00 2026-06-06T05:48:46+00:00

I have the following requirement. I submit a Model object to a view as

  • 0

I have the following requirement. I submit a Model object to a view as follows…

@RequestMapping(value ="/addItem", method = RequestMethod.GET)
     public ModelAndView showContacts() {           
         ModelAndView modelAndView = new ModelAndView("addItem", "command", new Item());
         return modelAndView;
     }

But on post, I need to retrieve a value apart from the “Item” object (model) that is returned to me. I can’t have this variable be a part of the Item model object because it does not belong there. But I need it returned in order to act on that value. How can I get about doing this ?

I.e. In my JSP file, I have the following fields…

<form:input type="text" path="val1"/>
<form:input type="text" path="val2"/>
<form:input type="text" path="val3"/>

Out of the above, only fields val1 and val2 have mappings to the Item object, where as val3 does not. Nevertheless, I need the value of val3 passed back to my controller as well. The code I have right now to handle the POST is as follows, but I can’t figure out how to get the value for val3. The code does not compile right now because it says that there is no field or appropriate getter method in the Item class for val3.

@RequestMapping(value = "/postItem", method = RequestMethod.POST)
    public String postItem(@ModelAttribute("item") Item item , BindingResult result) {
        logger.info("Post Item:");
        return "home";
    }

How can I modify the above code to suite my requirement ?

Some guidance on this matter will be highly 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-06T05:48:47+00:00Added an answer on June 6, 2026 at 5:48 am

    You can pass a map as the model, and include all sorts of different things in there. You are not limited to a single domain object, that constructor is there as a convenience, it is not the only way to do it. There is a variation of the constructor:

    public ModelAndView(Object view,
                        Map model)
    
        Create a new ModelAndView given a View object and a model.
    
        Parameters:
            view - View object to render (usually a Servlet MVC View object)
            model - Map of model names (Strings) to model objects (Objects). 
            Model entries may not be null, but the model Map may be null if 
            there is no model data.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following requirement- 1. Get the A_MINUTES column value from TableA for
Hi i have following requirement. 1) A website will send a get request with
I have the following requirement I have a Employee class: public class Employee {
For a website implemented in Django/Python we have the following requirement: On a view
I have the following weird requirement. I am given: A list of some method
I am trying to get the following requirement to work. I have a test
I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'
I have following requirement in my application. A tableView with games title After selecting
I am developing a network protocol In which I have following requirement each node
In my android application, I have following requirement. Activity A --> Activity B(Go to

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.