私はスプリングブートを使用していますが、jsonobjectタイプのリクエストを使用する場合はrestcontrollerまたはコントローラを作成していますが、タイプを変更すると同じ動作をします。jsonobjectを使用してrestcontrollerを使用したスプリングブート
@Controller
@RequestMapping("rest/dummy")
public class CustomerController {
@GetMapping("test")
public ResponseEntity test(@RequestParam("req") JSONObject inputData) {
org.json.JSONObject response = new org.json.JSONObject();
response.put("abc", "123");
return new ResponseEntity(inputData.toString(), HttpStatus.OK);
}
のpom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20171018</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
私はそれを両方GETとPOSTタイプを使用したくないとも私は、データをその場で変更することができますよう、要求と応答の両方のためにjsonobject使用したいとタイプ。
可能な重複と同じdoesntの仕事を使用して作業ガット(HTTPS:/ /stackoverflow.com/questions/44839753/returning-json-object-as-response-in-spring-boot) – utpal416