san*_*ity 6 java jersey grizzly
按照这里的说明我有这个代码:
private static URI getBaseURI() {
return UriBuilder.fromUri("http://localhost/").port(9998).build();
}
public static final URI BASE_URI = getBaseURI();
protected static HttpServer startServer() throws IOException {
System.out.println("Starting grizzly...");
final ResourceConfig rc = new PackagesResourceConfig("amplify.api.resources");
return GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
}
public static void main(final String[] args) throws IOException {
final HttpServer httpServer = startServer();
System.out.println(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\nTry out %shelloworld\nHit enter to stop it...", BASE_URI, BASE_URI));
System.in.read();
httpServer.stop();
}
Run Code Online (Sandbox Code Playgroud)
接下来我想启用这里描述的JSON POJO支持,但问题是我想以编程方式而不是通过web.xml文件(我没有web.xml文件!)来完成.
如何修改上面的代码以启用JSON POJO映射功能?
Pav*_*cek 10
protected static HttpServer startServer() throws IOException {
System.out.println("Starting grizzly...");
final ResourceConfig rc = new PackagesResourceConfig("amplify.api.resources");
rc.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true);
return GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6070 次 |
| 最近记录: |