2

(web.xml ではなく) Guice モジュールとして次の構成があります。

public class RestModule extends JerseyServletModule {
@Override
protected void configureServlets() {
    install(new JpaPersistModule("myDB"));
    filter("/*").through(PersistFilter.class);

    bind(CustomerList.class);
    bind(OrdersList.class);

    bind(MessageBodyReader.class).to(JacksonJsonProvider.class);
    bind(MessageBodyWriter.class).to(JacksonJsonProvider.class);

    ImmutableMap<String, String> settings = ImmutableMap.of(
            JSONConfiguration.FEATURE_POJO_MAPPING, "true"
            );

    serve("/*").with(GuiceContainer.class, settings);
}
}

REST エンドポイントへのサービス提供は、すでに非常にうまく機能しています。

ユーザーがhttp://example.com/をリクエストしたときに、/webapp/index.html から静的な html ファイルを提供したいと思います。

その他のサービスはhttp://example.com/customersまたはhttp://example.com/ordersにあります

私は web.xml を使用しません。ウェブサーバーは桟橋です

4

2 に答える 2

2

参照:Jersey / *サーブレットマッピングにより、静的リソース で404エラーが発生し、オブジェクトに適切なパラメータが追加されますsettings。何かのようなもの:

ImmutableMap<String, String> settings = ImmutableMap.of(
  JSONConfiguration.FEATURE_POJO_MAPPING, "true"
  "com.sun.jersey.config.property.WebPageContentRegex", "/.*html");
于 2013-03-17T22:16:56.293 に答える