java - rest services- pass parameters in key value format -


here controller:

@restcontroller @requestmapping("/warning/data") public class earlywarningdatacontroller {      @requestmapping(value = "/get/{soeid}/{gfcid}/{expressioncode}/{fiscalyear}/{timeperiod}",                  method = requestmethod.get)         public string getearlywarningdata(@pathvariable("soeid") string soeid,                 @pathvariable("gfcid") string[] gfcid,                 @pathvariable("expressioncode") string expressioncode,                 @pathvariable("fiscalyear") long fiscalyear,                 @pathvariable("timeperiod") string timeperiod) throws ioexception {         sysout("");     } 

when hit url

htpt://xyz:8080/earlywarning/warning/data/get/samplesoeid/1005771621/cat_total_rev/2012/annual  

it works fine.

but want send url like:

htpt://xyz:8080/earlywarning/warning/data/get/soeid=samplesoeid/gfcid=1005771621/expressioncode=cat_total_rev/fiscalyear=2012/timeperiod=annual 

what changes in code need do? pl help.

you should maybe convert parameters @requestparam, not @pathvariable. @requestparams essentialy query parameters (those after ? in url, divided &, http://www.example.com?field1=value1&field2=value2&field3=value3...).

you can find documentation here : http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/bind/annotation/requestparam.html

difference between @pathvariable , @requestparam discussed here: @requestparam vs @pathvariable


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -