<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 一、環境 1、Eclipse Juno R2 2. Tomcat 7 3. Jersey 2.7 ?下載地址(?https://jersey.java.net/download.html) ## 二、流程 1.Eclipse 中創建一個 Dynamic Web Project ,本例為“RestDemo” 2.按個各人習慣建好包,本例為“com.waylau.rest.resources” ![](https://box.kancloud.cn/2016-02-24_56cd25fc52599.png) 3.解壓jaxrs-ri-2.7, 將api、ext、lib文件夾下的jar包都放到項目的lib下; ![](https://box.kancloud.cn/2016-02-24_56cd25fc7154b.png) 項目引入jar包 ![](https://box.kancloud.cn/2016-02-24_56cd25fc87090.png) 4.在resources包下建一個class“HelloResource” ~~~ package com.waylau.rest.resources; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; @Path("/hello") public class HelloResource { @GET @Produces(MediaType.TEXT_PLAIN) public String sayHello() { return "Hello World!" ; } @GET @Path("/{param}") @Produces("text/plain;charset=UTF-8") public String sayHelloToUTF8(@PathParam("param") String username) { return "Hello " + username; } } ~~~ 5.修改web.xml,添加基于Servlet-的部署 ~~~ <servlet> <servlet-name>Way REST Service</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com.waylau.rest.resources</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Way REST Service</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> ~~~ 6.項目部署到tomcat,運行 7.瀏覽器輸入要訪問的uri地址 [http://localhost:8089/RestDemo/rest/hello](http://localhost:8089/RestDemo/rest/hello) 輸出Hello World! ![](https://box.kancloud.cn/2016-02-24_56cd25fca41e0.png) [http://localhost:8089/RestDemo/rest/hello/Way你好嗎](http://localhost:8089/RestDemo/rest/hello/Way你好嗎) 輸出Hello Way你好嗎 ![](https://box.kancloud.cn/2016-02-24_56cd25fcbd7ac.png) 參考:https://jersey.java.net/documentation/latest/user-guide.html
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看