I am using javax.servlet.Registration
to dynamically configure/register servlets.
I'd like to know how I could configure multiple provider packages for Jersey
. I can add a single package using the setInitParamater
method as follows:
public class MyWebInitalization implements WebApplicationInitializer {
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
//... some code
final ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", ServletContainer.class);
dispatcher.setInitParameter("jersey.config.server.provider.packages", "com.package1"); // how to add more packages?
//... more code
}
}
To give you an idea of what I mean, this is an equivalent if I would have used web.xml:
<servlet>
...
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.package1;com.package2</param-value>
</init-param>
...
</servlet>
Do you try something like this dispatcher.setInitParameter("jersey.config.server.provider.packages", "com.package1;com.package2");
?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.