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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:54:56+00:00 2026-05-22T16:54:56+00:00

A service class has a @GET operation that accepts multiple parameters. These parameters are

  • 0

A service class has a @GET operation that accepts multiple parameters. These parameters are passed in as query parameters to the @GET service call.

@GET
@Path("find")
@Produces(MediaType.APPLICATION_XML)
public FindResponse find(@QueryParam("prop1") String prop1, 
                         @QueryParam("prop2") String prop2, 
                         @QueryParam("prop3") String prop3, 
                         @QueryParam("prop4") String prop4, ...) 

The list of these parameters are growing, so I would like to place them into a single bean that contains all these parameters.

@GET
@Path("find")
@Produces(MediaType.APPLICATION_XML)
public FindResponse find(ParameterBean paramBean) 
{
    String prop1 = paramBean.getProp1();
    String prop2 = paramBean.getProp2();
    String prop3 = paramBean.getProp3();
    String prop4 = paramBean.getProp4();
}

How would you do this? Is this even possible?

  • 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-22T16:54:57+00:00Added an answer on May 22, 2026 at 4:54 pm

    You can use com.sun.jersey.spi.inject.InjectableProvider.

    import java.util.List;
    import java.util.Map.Entry;
    
    import javax.ws.rs.QueryParam;
    import javax.ws.rs.core.Context;
    import javax.ws.rs.core.MultivaluedMap;
    import javax.ws.rs.ext.Provider;
    
    import org.springframework.beans.BeanUtils;
    
    import com.sun.jersey.api.core.HttpContext;
    import com.sun.jersey.api.model.Parameter;
    import com.sun.jersey.core.spi.component.ComponentContext;
    import com.sun.jersey.core.spi.component.ComponentScope;
    import com.sun.jersey.spi.inject.Injectable;
    import com.sun.jersey.spi.inject.InjectableProvider;
    
    @Provider
    public final class ParameterBeanProvider implements InjectableProvider<QueryParam, Parameter> {
    
        @Context
        private final HttpContext hc;
    
        public ParameterBeanProvider(@Context HttpContext hc) {
            this.hc = hc;
        }
    
        @Override
        public ComponentScope getScope() {
            return ComponentScope.PerRequest;
        }
    
        @Override
        public Injectable<ParameterBean> getInjectable(ComponentContext ic, final QueryParam a, final Parameter c) {
    
            if (ParameterBean.class != c.getParameterClass()) {
                return null;
            }
    
            return new Injectable<ParameterBean>() {
    
                public ParameterBean getValue() {
                    ParameterBean parameterBean = new ParameterBean();
                    MultivaluedMap<String, String> params = hc.getUriInfo().getQueryParameters();
                    // Populate the parameter bean properties
                    for (Entry<String, List<String>> param : params.entrySet()) {
                        String key = param.getKey();
                        Object value = param.getValue().iterator().next();
    
                        // set the property
                        BeanUtils.setProperty(parameterBean, key, value);
                    }
                    return parameterBean;
                }
            };
        }
    }
    

    In your resource you just have to use @QueryParam("valueWeDontCare").

    @GET
    @Path("find")
    @Produces(MediaType.APPLICATION_XML)
    public FindResponse find(@QueryParam("paramBean") ParameterBean paramBean) {
        String prop1 = paramBean.getProp1();
        String prop2 = paramBean.getProp2();
        String prop3 = paramBean.getProp3();
        String prop4 = paramBean.getProp4();
    }
    

    The provider will be automatically called.

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

Sidebar

Related Questions

I have a service class which has overloaded constructors. One constructor has 5 parameters
Suppose the .NET Component Model. The Container class has GetService(Type service); But I'm asking
I have a web service class that the rest of the framework depends on
Given that I have the following WCF service: class LookUpService { public List<County> GetCounties(string
I have a wcf service. The service itself (class that inherits the ServiceContract )
In Silverlight 4 I have a custom service class which has an asynchronous Completed
I have a custom domain service with a single [Invoke] operation that returns a
I have a web service that accepts an Invoice, which contains LineItem children. It
I have a property in WCF service class with a initial value, as shown
One thing I've run into a few times is a service class (like a

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.