简体   繁体   English

REST Web服务部署描述符查询Java

[英]Rest Web Service deployment descriptor query java

am working on implementing Rest web service and need clarification on the deployment descriptor file. 正在实施Rest Web服务,并且需要澄清部署描述符文件。 Below is the web.xml code and what I have understood is that whenever the url contains /webapi/ the ServletContainer class gets invoked. 下面是web.xml代码,据我了解,只要URL包含/ webapi /,就调用ServletContainer类。 Please correct me if am wrong till this point. 到目前为止,如果有错,请纠正我。 Further can you tell me what's the significance of the attributes param-name and param-value. 您还可以告诉我参数param-name和param-value的意义是什么。 Is it that the package mentioned in the param-value is passed as argument to the ServletContainer class? 是否将param-value中提到的包作为参数传递给ServletContainer类?

<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml file is not required when using Servlet 3.0 container,
     see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html -->
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <servlet>
        <servlet-name>Jersey Web Application</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>org.xyz.ws.transporter</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey Web Application</servlet-name>
        <url-pattern>/webapi/*</url-pattern>
    </servlet-mapping>
</web-app>

Thanks in advance for your help. 在此先感谢您的帮助。

I have understood is that whenever the url contains /webapi/ the ServletContainer class gets invoked. 我了解的是,每当URL包含/ webapi /时,ServletContainer类就会被调用。

True. 真正。

Further can you tell me what's the significance of the attributes param-name and param-value 您还可以告诉我参数param-name和param-value的意义是什么

init-param s are basically just configuration properties that the servlet/filter can use to configure itself. init-param基本上只是servlet / filter可以用来配置自身的配置属性。

Here you are configuring a specific property named jersey.config.server.provider.packages , with the value of org.xyz.ws.transporter . 在这里,您将配置一个名为jersey.config.server.provider.packages的特定属性,其值为org.xyz.ws.transporter Jersey will use the value of the this specific configuration property to set up package scanning. Jersey将使用此特定配置属性的值来设置程序包扫描。 Jersey will scan the package you specify (recursively) for classes annotated with @Provider and @Path . 泽西岛将(递归)扫描您指定的包中是否带有@Provider@Path注释的类。 This allows Jersey to register all resources and provider classes. 这允许Jersey注册所有资源和提供程序类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM