如何设置Jersey init param?

时间:2017-01-26 23:36:52

标签: glassfish payara

我需要将jersey.config.server.response.setStatusOverSendError配置设置为true

1 个答案:

答案 0 :(得分:2)

通过在自定义getProperties()类中提供重写方法Application,可以在JAX-RS应用程序中设置Jersey属性,例如在this example in Jersey tests中:

public class MyApplication extends Application {

    @Override
    public Map<String, Object> getProperties() {
        return new HashMap<String, Object>() {{
            put("jersey.config.server.response.setStatusOverSendError", true);
        }};
    }
}

web.xml中的Jersey servlet的init-param应该可以实现同样的功能,就像在this Jersey test app中一样:

<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>org.glassfish.jersey.tests.integration.servlettests</param-value>
        </init-param>