java - Jersey - Marshal Object from HTTP Headers -


is possible have jersey take series of http headers , marshall them pojo, 1 might post parameters?

if want access specific @headerparam string, use answers provided @juned ahsan or @dj spiess. if want inject them pojo, recommend using jersey's @beanparam in 2.x.

for example:

@path("/foo") public class fooresource {     @get     @path("/bar")     public void bar(@beanparam mybean mybean) {       //     } }  public class mybean {     private string uacompatible;      public mybean(@headerparam("x-ua-compatible") string uacompatible) {         this.uacompatible = uacompatible;     }      public string getuacompatible() {         return this.uacompatible;     } } 

@beanparam can replaced @injectparam jersey 1.x (>=1.4) or @inject in 1.x earlier 1.4. javax-@inject can used if you're using dependency injection framework such spring.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -