Den 16. aug.. 2009 kl. 07.55 skrev jaxzin:
>
> So I'd like my resources to support path suffixes like '.xml' and
> '.json' to
> make is simpler for users to choose their response format without
> needing to
> set the Accept header properly. Is there anything similar built into
> Jersey such as a query param it looks for or something?
Override getMediaTypeMappings in your appconfig, something like this:
public class AppConfig extends PackagesResourceConfig {
private Map<String, MediaType> mapping;
public AppConfig(Map<String, Object> props) {
super(props);
init();
}
public AppConfig(String[] packages) {
super(packages);
init();
}
@Override
public Map<String, MediaType> getMediaTypeMappings() {
return mapping;
}
private void init() {
mapping = new HashMap<String, MediaType>();
mapping.put("xml", MediaType.APPLICATION_XML_TYPE);
mapping.put("html", MediaType.TEXT_HTML_TYPE);
}
}
Jo