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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:22:02+00:00 2026-06-10T15:22:02+00:00

I have a rest application that returns json/xml. I use jackson and jaxb for

  • 0

I have a rest application that returns json/xml. I use jackson and jaxb for conversion. Some methods need to accept a query_string. I’ve used @ModelAttribute to map the query_string into an object, but this forces the object into my view. I do not want the object to appear in the view.

I think I need to use something other than @ModelAttribute, but I can’t figure out how to do the binding, but not modify the view. If I omit @ModelAttribute annotation, the object appears in the view as the variable name (eg: “sourceBundleRequest”).

Example Url:

http://localhost:8080/rest/sourcebundles/?updateDate=20100501&label=urgent

Controller Method:

@RequestMapping(value = {"", "/"}, method = RequestMethod.GET)
public String getAll(@ModelAttribute("form") SourceBundleRequest sourceBundleRequest, BindingResult result, ModelMap model) throws ApiException {
    // Detect and report errors.
    if (result.hasErrors()) {
       // (omitted for clarity)
    }

    // Fetch matching data.
    PaginatedResponse<SourceBundle> sourceBundleResponse = null;
    try {
        int clientId = getRequestClientId();
        sourceBundleResponse = sourceBundleService.get(clientId, sourceBundleRequest);
    } catch (ApiServiceException e) {
        throw new ApiException(ApiErrorType.INTERNAL_ERROR, "sourceBundle fetch failed");
    }

    // Return the response.
    RestResponse<PaginatedResponse> restResponse = new RestResponse<PaginatedResponse>(200, "OK");
    restResponse.setData(sourceBundleResponse);
    model.addAttribute("resp", restResponse);
    // XXX - how do I prevent "form" from appearing in the view?
    return "restResponse";
}

Example Output:

"form": {
    "label": "urgent",
    "updateDate": 1272697200000,
    "sort": null,
    "results": 5,
    "skip": 0
},
"resp": {
    "code": 200,
    "status": "OK",
    "data": {
        "totalAvailable": 0,
        "resultList": [ ]
    }
}

Desired Output:

"resp": {
    "code": 200,
    "status": "OK",
    "data": {
        "totalAvailable": 0,
        "resultList": [ ]
    }
}

Omitting @ModelAttribute(“form”)

If I simply omit @ModelAttribute(“form”), I still get the undesirable response but the incoming form is named by the object name. The response looks like this:

"resp": {
    "code": 200,
    "status": "OK",
    "data": {
        "totalAvailable": 0,
        "resultList": [ ]
    }
},
"sourceBundleRequest": {
    "label": "urgent",
    "updateDate": 1272697200000,
    "sort": null,
    "results": 5,
    "skip": 0
}
  • 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-10T15:22:03+00:00Added an answer on June 10, 2026 at 3:22 pm

    Somehow I missed the most obvious way to fix this. I was focused on the Attributes and forgot that I can just modify the underlying Map.

      // Remove the form object from the model map.
      model.remove("form");
    

    It might be a little more efficient to omit @ModelAttribute as Biju suggested and then remove the sourceBundleRequest object. I suspect @ModelAttribute has some additional overhead.

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

Sidebar

Related Questions

I have a portion of my site that has a lightweight xml/json REST API.
I have a Jersey REST service which has endpoints that can return either application/xml
I have an application that uses rest to communicate to a server, i would
I have an asp.net 4 application that hosts a WCF REST service via WebServiceHost...
I have ASP MVC 3 application. I created WCF REST JSON Service and added
I use Backbone.js and jQuery 1.7 in my application and I have some problems
I have a (REST) application that handles CRUD operations initiated by a 3rd party,
I have a modular software, one module must be a webserver that accept REST
I am trying to build an REST web service that returns JSON for all
I have a REST web service that returns a javax.ws.rs.core.Response entity. When I run

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.