Is it possible to map parameters to a path in Spring Rest?

I've a legacy system where query parameters are used to determine the class/method for a request using a simple in-house framework. E.g.

/endpoint?product=foo&action=bar&amount=1.0
/endpoint?product=foo&action=baz&amount=1.0

And I'd like map all actions for a product to one class so the plumbing can be greatly simplified, e.g.

@Controller
@RequestMapping("/endpoint/foo/**")
public class FooController {

  @AutoWire
  private FooProductService s; // one of many beans that have to be wired into lots of classes

  @RequestMapping("/bar")
  public void bar(@PathVariable String amount, Model model) {    
    // implementation omitted
  }
  @RequestMapping("/baz")
  public void baz(@PathVariable String amount, Model model) {    
    // implementation omitted
  }

}

It's a published API so we can't change the public API -> the URLs cannot change.

I thought that perhaps this could be done using configuration, as aspect or even a custom framework with out own annotations.

Answers


I believe you can do something like this for product=foo&action=bar&amount=1.0

@RequestMapping(value = "product={productName}&action={someaction}&amount={value}", method=RequestMethod.GET)
something(@PathVariable String productName, @PathVariable String someaction, @PathVariable String value)
    if(someaction.equals("bar")) {
        //do bar
    } 
    if(someaction.equals("baz")) {
        //do baz
    } 
}

HTH


Need Your Help

ld linker script error

linux linker gnu

The project I'm currently working on uses a bunch of dynamic libs bundled together with the source code. There is a subset of libs which is named as follows:

Adding Numbers that are coming from ArrayList

ios add store

Here is my Problem, I was able to get the ArrayList (no of Hours) from JSON, The problem is I want to add all the Hours and store the same into a variable so that I can access for next page. Simply

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.