Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 790 Bytes

09.md

File metadata and controls

33 lines (24 loc) · 790 Bytes

9. ResourceでJSONをレスポンスしよう

pom.xml の dependency を追加する。

...
<dependencies>
  <dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-grizzly2-http</artifactId>
  </dependency>

  <!-- 下の4行のコメントアウトを解除 -->
  <dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-moxy</artifactId>
  </dependency>
  ...

ProductResource クラスの @Produces の値を MediaType.APPLICATION_JSON に変更する。

javado.lec06.Main を実行しなおす。

http://localhost:8080/myapp/product にアクセスして、下のようなJSONが表示されればOK。

{"id":200,"name":"Java Do","price":2800}

--

戻る