Spring MVC RequestMapping ParamRequest collection/array

I have a @Controller with a @RequestMapping functions that accept collections.

Imagine something like:

requestHandler(Collection<Long> param){
   ...
}

This mapping only matches when I send requests such as:

http://www.domain.com/mapping/funct?param=1&param=2&param=3

I'd like to match it as well when I send a comma sepparated value:

 http://www.domain.com/mapping/funct?param=1,2,3

Is there a way without using .split ? I'd like it to be automatically parsed to a collection.

Answers


You would have to write a custom Converter and register it in your Spring MVC context.


It is better to access all query parameters and parse according to your needs in this type of scenarios

You should have access to the requests query string via request.getQueryString().

In addition to getQueryString, the query parameters can also be retrieved from request.getParameterMap() as a Map.


Need Your Help

Scrolling a ViewController Swift

ios swift uiscrollview xcode6

I am trying to make a view controller scrollable because there is not enough room on the screen at one time to fit everything. I have checked out links from Google on how to do this

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.