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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:53:05+00:00 2026-05-18T11:53:05+00:00

I am using Spring MVC and I want to do a AJAX call to

  • 0

I am using Spring MVC and I want to do a AJAX call to get a JSON message with a Set of Person objects.
I have this jQuery code:

$(document).ready(function() {
    getAllPersons();
});
function getAllPersons() {
    $.getJSON("person/allpersons", function(data) {
        alert(data);
    });
}

The person/allpersons (REST URL) calls a RequestMapping:

@RequestMapping(value="/allersons", method=RequestMethod.GET)
public @ResponseBody ??? ???() {
    ???
}

I have a service implemented to get all Persons:

public interface IPersonService {
    public Person addPerson(Person p);
    ...
    public Set<Person> getAllPersons();
}

How can I call this service? So what do I have to place instead of the ???

I tried several things like this, but I get errors in my Eclipse IDE:

public @ResponseBody <Set>Person getSomething() {
    Set<Person> persons = IPersonService.getAllPersons();
    return persons;
}

Errors / Warnings:

The type parameter Set is hiding the type Set<E>
Cannot make a static reference to the non-static method getAllPersons() from the type IPersonService
The type Set is not generic; it cannot be parameterized with arguments <Person>

Any suggestions?

Thank you in advance & Best Regards.

  • 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-18T11:53:05+00:00Added an answer on May 18, 2026 at 11:53 am

    In your method Person is wrong it should be Set

    public @ResponseBody Set<Person> getSomething() {
        Set<Person> persons = new IPersonServiceImpl().getAllPersons();
        return persons;
    }
    

    and another thing is you can not call interface method directly, first you need to implement that method in implementation class.

    IPersonService.getAllPersons() This statement is wrong , here compiler considering it as static method getAllPersons() of IPersonService class.

    public class IPersonServiceImpl implements IPersonService{
        public Set<Person> getAllPersons(){
         -- Your Business Logic
        }
        public Person addPerson(Person p){
         -- Your Business Logic
        }
    }
    

    }

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

Sidebar

Related Questions

I am using Spring MVC 3 and I want to make an AJAX call
I am using this sample Spring MVC project with AJAX / JSON support: https://src.springframework.org/svn/spring-samples/mvc-ajax/
I'm using Spring MVC and jquery autocomplete, my spring controller looks like this @RequestMapping(value
Following is the Javascript function which is using AJAX call in my Spring MVC
I've been having a problem regarding using AJAX with Spring MVC. I have a
I'm using spring MVC, and I have a custom authentication/security system that I had
This is an example of using ThrowawayController in Spring MVC: public class DisplayCourseController implements
I am using Spring Web MVC for my application. I have 1 dropdown list
I am trying to access object using ajax in spring MVC. So its like
I have an ASP.Net MVC page where I want to use AJAX to update

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.