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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:42:17+00:00 2026-06-05T07:42:17+00:00

Is it possible to use both @RequestMapping and @ModelAttribute annotations on the same method

  • 0

Is it possible to use both @RequestMapping and @ModelAttribute annotations on the same method in a Spring MVC Controller?

For example I’d like to obtain something like:

@ModelAttribute("export_profiles")
@RequestMapping(value = "/profiles_list", method = RequestMethod.GET)
public @ResponseBody
ExportProfile[] getExportProfilesList() {
    edService.getProfiles();
}

I’d like to use this approach because, in my page I have to load a list of ExportProfiles as options into a select. In the same page I can create/delete export profiles, so I have to refresh the profiles list in my select, and I’d like to do this asynchronously using an ajax call to the same metod.

Is it possible to use a single method to set a model attribute and to handle asynchronous requests? Or do I have to use two different methods?

  • 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-05T07:42:18+00:00Added an answer on June 5, 2026 at 7:42 am

    What I want to do is to set an ExportProfile array as model attribute,
    to populate a select the first time I load the page

    you can just set an attribute of a page like so …

    public String myMethodThatInitiatesPage(Model model) {
      model.addAttribute("exportProfiles", edService.getProfiles())
    return "yrViewName";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know: If it's possible to use Lazarus (Pascal) for both
I'd like to use both the CSS :before pseudoclass and the jQuery .before() method
Is it possible to use both JScript and VBScript in the same HTA? Can
Is it possible to use variables in both fields of the gsub method ?
Please tell me whether it is possible to use both SimpleUrlHandlerMapping and AnnotationMapping in
Is it possible to use Python to write cross-platform apps for both iOS and
Is it possible to call a spring controller from javascript included in a jsp?
Is it possible to use both NTLM and Forms Authentication on once native instance
Possible Duplicate: When to use interfaces or abstract classes? When to use both? Consider
I have a rails application where I would like to use both memcached and

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.