{"id":778,"date":"2023-09-12T08:32:10","date_gmt":"2023-01-30T22:49:30","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/index.php\/2023\/11\/30\/%e6%98%a5%e3%81%aerestcontroller\/"},"modified":"2025-08-01T02:24:02","modified_gmt":"2025-07-31T17:24:02","slug":"%e6%98%a5%e3%81%aerestcontroller","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/","title":{"rendered":"\u6625\u306eRestController"},"content":{"rendered":"<p>Spring RestController\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306f\u3001@Controller\u3068@ResponseBody\u3067\u81ea\u4f53\u304c\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u3066\u3044\u308b\u4fbf\u5229\u306a\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u3059\u3002\u3053\u306e\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u30af\u30e9\u30b9\u306b\u9069\u7528\u3055\u308c\u3001\u305d\u308c\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u30cf\u30f3\u30c9\u30e9\u3068\u3057\u3066\u30de\u30fc\u30af\u3057\u307e\u3059\u3002Spring RestController\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306f\u3001Spring MVC\u3092\u4f7f\u7528\u3057\u3066RESTful\u306aWeb\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002Spring RestController\u306f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u5b9a\u7fa9\u3055\u308c\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u30cf\u30f3\u30c9\u30e9\u30e1\u30bd\u30c3\u30c9\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3059\u308b\u306e\u3092\u62c5\u5f53\u3057\u307e\u3059\u3002\u30cf\u30f3\u30c9\u30e9\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u751f\u6210\u3055\u308c\u305f\u30ec\u30b9\u30dd\u30f3\u30b9\u30dc\u30c7\u30a3\u304c\u751f\u6210\u3055\u308c\u308b\u3068\u3001\u305d\u308c\u3092JSON\u307e\u305f\u306fXML\u30ec\u30b9\u30dd\u30f3\u30b9\u306b\u5909\u63db\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30d7\u30ea\u30f3\u30b0\u306eRestController\u306e\u4f8b<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656499c1daa94e2bdf7c1118\/2-0.png\" alt=\"Spring RestController Example Project\" \/><\/div>\n<h2>\u6625\u306eRestController\u306eMaven\u306e\u4f9d\u5b58\u95a2\u4fc2<\/h2>\n<p>\u79c1\u305f\u3061\u306eSpring RestController\u306e\u4f8b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u5fc5\u8981\u306a\u4f9d\u5b58\u95a2\u4fc2\u3092\u78ba\u8a8d\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;dependency&gt;\r\n\t&lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;spring-webmvc&lt;\/artifactId&gt;\r\n\t&lt;version&gt;5.0.7.RELEASE&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n\t&lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;spring-web&lt;\/artifactId&gt;\r\n\t&lt;version&gt;5.0.7.RELEASE&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n\r\n&lt;!-- Jackson for REST JSON Support --&gt;\r\n&lt;dependency&gt;\r\n\t&lt;groupId&gt;com.fasterxml.jackson.core&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;jackson-databind&lt;\/artifactId&gt;\r\n\t&lt;version&gt;2.9.6&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;!-- JAXB for XML Response, needed to explicitly define from Java 9 onwards --&gt;\r\n&lt;dependency&gt;\r\n\t&lt;groupId&gt;javax.xml.bind&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;jaxb-api&lt;\/artifactId&gt;\r\n\t&lt;version&gt;2.3.0&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n\t&lt;groupId&gt;org.glassfish.jaxb&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;jaxb-runtime&lt;\/artifactId&gt;\r\n\t&lt;version&gt;2.3.0&lt;\/version&gt;\r\n\t&lt;scope&gt;runtime&lt;\/scope&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n\t&lt;groupId&gt;javax.activation&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;javax.activation-api&lt;\/artifactId&gt;\r\n\t&lt;version&gt;1.2.0&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n<\/code><\/pre>\n<p>REST\u30a6\u30a7\u30d6\u30b5\u30fc\u30d3\u30b9\u304b\u3089\u306eXML\u304a\u3088\u3073JSON\u306e\u8981\u6c42\u3068\u5fdc\u7b54\u3092\u30b5\u30dd\u30fc\u30c8\u3059\u308b\u305f\u3081\u306b\u3001Spring MVC\u3001Jackson\u3001\u304a\u3088\u3073JAXB\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u5fc5\u8981\u3067\u3059\u3002Web.xml\u30d5\u30a1\u30a4\u30eb\u306fSpring MVC DispatcherServlet\u3092\u30d5\u30ed\u30f3\u30c8\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3068\u3057\u3066\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u3067\u306f\u3001\u4eca\u5ea6\u306fSpring\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;beans:beans\r\n\txmlns=\"https:\/\/www.springframework.org\/schema\/mvc\"\r\n\txmlns:xsi=\"https:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n\txmlns:beans=\"https:\/\/www.springframework.org\/schema\/beans\"\r\n\txmlns:context=\"https:\/\/www.springframework.org\/schema\/context\"\r\n\txsi:schemaLocation=\"https:\/\/www.springframework.org\/schema\/mvc https:\/\/www.springframework.org\/schema\/mvc\/spring-mvc.xsd\r\n\t\thttps:\/\/www.springframework.org\/schema\/beans https:\/\/www.springframework.org\/schema\/beans\/spring-beans.xsd\r\n\t\thttps:\/\/www.springframework.org\/schema\/context https:\/\/www.springframework.org\/schema\/context\/spring-context.xsd\"&gt;\r\n\r\n\t&lt;!-- Enables the Spring MVC @Controller programming model --&gt;\r\n\t&lt;annotation-driven \/&gt;\r\n\r\n\t&lt;context:component-scan\r\n\t\tbase-package=\"com.scdev.spring\" \/&gt;\r\n\r\n\t&lt;beans:bean id=\"jsonMessageConverter\"\r\n\t\tclass=\"org.springframework.http.converter.json.MappingJackson2HttpMessageConverter\" \/&gt;\r\n\t&lt;beans:bean id=\"xmlMessageConverter\"\r\n\t\tclass=\"org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter\" \/&gt;\r\n\r\n\t&lt;beans:bean\r\n\t\tclass=\"org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter\"&gt;\r\n\t\t&lt;beans:property name=\"messageConverters\"&gt;\r\n\t\t\t&lt;beans:list&gt;\r\n\t\t\t\t&lt;beans:ref bean=\"jsonMessageConverter\" \/&gt;\r\n\t\t\t\t&lt;beans:ref bean=\"xmlMessageConverter\" \/&gt;\r\n\t\t\t&lt;\/beans:list&gt;\r\n\t\t&lt;\/beans:property&gt;\r\n\t&lt;\/beans:bean&gt;\r\n\r\n&lt;\/beans:beans&gt;\r\n<\/code><\/pre>\n<p>\u6700\u3082\u91cd\u8981\u306a\u90e8\u5206\u306f\u3001jsonMessageConverter\u3068xmlMessageConverter\u306eBean\u304cRequestMappingHandlerAdapter\u306emessageConverters\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u5b9a\u7fa9\u304a\u3088\u3073\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3067\u3059\u3002\u3053\u308c\u3060\u3051\u3067\u3001Spring\u306b\u79c1\u305f\u3061\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304cJSON\u3068XML\u306e\u4e21\u65b9\u3092\u30b5\u30dd\u30fc\u30c8\u3059\u308b\u3053\u3068\u3092\u4f1d\u3048\u3001\u5909\u63db\u306b\u4f7f\u7528\u3059\u308bBean\u3067\u3042\u308b\u3053\u3068\u3092\u793a\u3059\u305f\u3081\u306b\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<h2>\u6625\u306eRestController\u30af\u30e9\u30b9<\/h2>\n<p>\u79c1\u305f\u3061\u306eSpring RestController\u30af\u30e9\u30b9\u306e\u5b9f\u88c5\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.spring.controller;\r\n\r\nimport java.util.List;\r\n\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\nimport org.springframework.web.bind.annotation.DeleteMapping;\r\nimport org.springframework.web.bind.annotation.GetMapping;\r\nimport org.springframework.web.bind.annotation.PathVariable;\r\nimport org.springframework.web.bind.annotation.PostMapping;\r\nimport org.springframework.web.bind.annotation.RequestBody;\r\nimport org.springframework.web.bind.annotation.RestController;\r\n\r\nimport com.scdev.spring.model.Employee;\r\nimport com.scdev.spring.repository.EmployeeRepository;\r\n\r\n@RestController\r\npublic class EmployeeRestController {\r\n\r\n\t@Autowired\r\n\tprivate EmployeeRepository repository;\r\n\t\r\n\t@GetMapping(\"\/rest\/employee\/get\/{id}\")\r\n\tpublic Employee getEmployeeByID(@PathVariable(\"id\") int id) {\r\n\t\treturn repository.retrieve(id);\r\n\t}\r\n\t\r\n\t@GetMapping(\"\/rest\/employee\/getAll\")\r\n\t\/\/Returning is List is supported with JSON response only\r\n\t\/\/If you want XML, then add a wrapper class as Root XML element, for example EmployeeList\r\n\tpublic List&lt;Employee&gt; getAllEmployees() {\r\n\t\treturn repository.getAll();\r\n\t}\r\n\r\n\t@PostMapping(\"\/rest\/employee\/create\")\r\n\tpublic Employee createEmployee(@RequestBody Employee emp) {\r\n\t\trepository.store(emp);\r\n\t\treturn emp;\r\n\t}\r\n\t\r\n\t@GetMapping(\"\/rest\/employee\/search\/{name}\")\r\n\tpublic Employee getEmployeeByName(@PathVariable(\"name\") String name) {\r\n\t\treturn repository.search(name);\r\n\t}\r\n\t\r\n\t@DeleteMapping(\"\/rest\/employee\/delete\/{id}\")\r\n\tpublic Employee deleteEmployeeByID(@PathVariable(\"id\") int id) {\r\n\t\treturn repository.delete(id);\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>\u3053\u3053\u3067\u306f\u3001\u79c1\u305f\u3061\u306fREST API\u306e\u307f\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3059\u3079\u3066\u306e\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u306fRepository\u30af\u30e9\u30b9\u306e\u4e00\u90e8\u3067\u3059\u3002\u30e1\u30bd\u30c3\u30c9\u304c\u30ea\u30b9\u30c8\u307e\u305f\u306f\u914d\u5217\u3092\u8fd4\u3059\u5834\u5408\u3001Spring\u306fJSON\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u307f\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002\u306a\u305c\u306a\u3089\u3001XML\u30eb\u30fc\u30c8\u8981\u7d20\u306f\u533f\u540d\u3067\u3042\u308b\u3053\u3068\u304c\u3067\u304d\u305a\u3001JSON\u306f\u3067\u304d\u308b\u304b\u3089\u3067\u3059\u3002\u30ea\u30b9\u30c8\u3092XML\u3068\u3057\u3066\u8fd4\u3059\u30b5\u30dd\u30fc\u30c8\u3092\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u3053\u306e\u30ea\u30b9\u30c8\u3092\u4fdd\u6301\u3059\u308b\u30e9\u30c3\u30d1\u30fc\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3066\u8fd4\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3044\u304f\u3064\u304b\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u3068\u3057\u3066Employee\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u671f\u5f85\u3057\u3066\u3044\u307e\u3059\u3002Spring\u306f\u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u3092\u89e3\u6790\u3057\u3001\u3053\u308c\u3089\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u305f\u3081\u306eEmployee\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5909\u63db\u3059\u308b\u51e6\u7406\u3092\u62c5\u5f53\u3057\u307e\u3059\u3002\u540c\u69d8\u306b\u3001Response Body\u3068\u3057\u3066Employee\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8fd4\u3057\u307e\u3059\u304c\u3001\u518d\u3073Spring\u304cJSON\/XML\u30ec\u30b9\u30dd\u30f3\u30b9\u306b\u5909\u63db\u3059\u308b\u51e6\u7406\u3092\u62c5\u5f53\u3057\u307e\u3059\u3002<\/p>\n<h2>\u53d7\u3051\u5165\u308c\u304a\u3088\u3073Content-Type\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u30d8\u30c3\u30c0\u30fc\u3092\u53d7\u3051\u5165\u308c\u308b<\/h2>\n<p>REST\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092XML\u3068JSON\u306e\u4e21\u65b9\u3067\u52d5\u4f5c\u3059\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3057\u305f\u3002\u3060\u304b\u3089\u3001\u305d\u308c\u306f\u30ea\u30af\u30a8\u30b9\u30c8\u304cXML\u304bJSON\u304b\u3092\u3069\u306e\u3088\u3046\u306b\u77e5\u308b\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u305d\u3057\u3066\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u306fJSON\u5f62\u5f0f\u304bXML\u5f62\u5f0f\u3067\u9001\u4fe1\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u305d\u308c\u306b\u306f\u3001Accept\u3068Content-Type\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u30d8\u30c3\u30c0\u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002Content-Type\u306f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u30bf\u30a4\u30d7\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u5024\u304c\u300capplication\/xml\u300d\u306e\u5834\u5408\u3001Spring\u306f\u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u3092XML\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3068\u3057\u3066\u6271\u3044\u307e\u3059\u3002\u5024\u304c\u300capplication\/json\u300d\u306e\u5834\u5408\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u306fJSON\u3068\u3057\u3066\u6271\u308f\u308c\u307e\u3059\u3002Accept\u306f\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304c\u53d7\u3051\u53d6\u308b\u4e88\u5b9a\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30bf\u30a4\u30d7\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u5024\u304c\u300capplication\/xml\u300d\u306e\u5834\u5408\u3001XML\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u9001\u4fe1\u3055\u308c\u307e\u3059\u3002\u5024\u304c\u300capplication\/json\u300d\u306e\u5834\u5408\u3001JSON\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u9001\u4fe1\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>\u6625\u306eRestController\u30c6\u30b9\u30c8<\/h2>\n<p>\u79c1\u305f\u3061\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u30c6\u30b9\u30c8\u306e\u6e96\u5099\u304c\u6574\u3063\u3066\u3044\u307e\u3059\u3002\u79c1\u306fTomcat-9\u306b\u30c7\u30d7\u30ed\u30a4\u3057\u3066\u3001Postman\u3067\u30c6\u30b9\u30c8\u3057\u3066\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u30c6\u30b9\u30c8\u7d50\u679c\u3068\u8aac\u660e\u3067\u3059\u3002<\/p>\n<h3>Spring\u306eRestController\u306b\u3088\u308bJSON\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u53d6\u5f97<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656499c1daa94e2bdf7c1118\/18-0.png\" alt=\"Spring RestController GET JSON Response\" \/><\/div>\n<h3>\u300cSpring\u306eRestController\u3067GET\u30e1\u30bd\u30c3\u30c9\u3067XML\u5f62\u5f0f\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u53d6\u5f97\u3059\u308b\u300d<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656499c1daa94e2bdf7c1118\/20-0.png\" alt=\"Spring REST XML Response Accept header\" \/><\/div>\n<h3>\u6625\u306eRestController\u306bGET\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\u3059\u308b\u3002<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656499c1daa94e2bdf7c1118\/22-1.png\" alt=\"Spring REST GET List XML\" \/><\/div>\n<h3>\u6625\u306eRestController\u3067\u306ePOST<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656499c1daa94e2bdf7c1118\/24-2.png\" alt=\"Spring RestController POST JSON Request and XML Response\" \/><\/div>\n<h3>Spring Framework\u306eRestController DELETE<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656499c1daa94e2bdf7c1118\/26-1.png\" alt=\"Spring RestController DELETE XML Response\" \/><\/div>\n<h2>\u8981\u7d04: \u3053\u306e\u8981\u7d04\u3067\u306f\u3001\u65e5\u672c\u8a9e\u3067\u30cd\u30a4\u30c6\u30a3\u30d6\u306a\u8a00\u3044\u65b9\u3067\u4ee5\u4e0b\u3092\u518d\u8868\u73fe\u3057\u307e\u3059\u3002<\/h2>\n<p>Spring\u306eRestController\u306f\u3001REST\u30a6\u30a7\u30d6\u30b5\u30fc\u30d3\u30b9\u306eAPI\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u7169\u96d1\u306a\u624b\u7d9a\u304d\u3092\u5168\u3066\u51e6\u7406\u3057\u3066\u304f\u308c\u308b\u3053\u3068\u3067\u3001\u79c1\u305f\u3061\u304c\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u306b\u96c6\u4e2d\u3059\u308b\u306e\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u79c1\u305f\u3061\u306eGitHub\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u5168\u4f53\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring RestController\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306f\u3001@Controller\u3068@ResponseBody\u3067\u81ea\u4f53\u304c\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u3066\u3044\u308b\u4fbf\u5229\u306a\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u3059\u3002\u3053\u306e\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u30af\u30e9\u30b9\u306b\u9069\u7528\u3055\u308c\u3001\u305d\u308c\u3092\u30ea\u30af\u30a8 [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26,61],"class_list":["post-778","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-26","tag-61"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6625\u306eRestController - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u6625\u306eRestController\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/\u6625\u306erestcontroller\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6625\u306eRestController\" \/>\n<meta property=\"og:description\" content=\"\u6625\u306eRestController\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/\u6625\u306erestcontroller\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-30T22:49:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T17:24:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656499c1daa94e2bdf7c1118\/2-0.png\" \/>\n<meta name=\"author\" content=\"\u6d77\u6597, \u8475\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6d77\u6597, \u8475\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"17\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/\",\"name\":\"\u6625\u306eRestController - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2023-01-30T22:49:30+00:00\",\"dateModified\":\"2025-07-31T17:24:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/20cfc053626f4d45c0fa7a4e7964b5b6\"},\"description\":\"\u6625\u306eRestController\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6625\u306eRestController\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/20cfc053626f4d45c0fa7a4e7964b5b6\",\"name\":\"\u6d77\u6597, \u8475\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g\",\"caption\":\"\u6d77\u6597, \u8475\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/kaitoaoi\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u6625\u306eRestController - Blog - Silicon Cloud","description":"\u6625\u306eRestController\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/ja\/blog\/\u6625\u306erestcontroller\/","og_locale":"ja_JP","og_type":"article","og_title":"\u6625\u306eRestController","og_description":"\u6625\u306eRestController\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/\u6625\u306erestcontroller\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-01-30T22:49:30+00:00","article_modified_time":"2025-07-31T17:24:02+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/656499c1daa94e2bdf7c1118\/2-0.png"}],"author":"\u6d77\u6597, \u8475","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u6d77\u6597, \u8475","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"17\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/","name":"\u6625\u306eRestController - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2023-01-30T22:49:30+00:00","dateModified":"2025-07-31T17:24:02+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/20cfc053626f4d45c0fa7a4e7964b5b6"},"description":"\u6625\u306eRestController\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"\u6625\u306eRestController"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/20cfc053626f4d45c0fa7a4e7964b5b6","name":"\u6d77\u6597, \u8475","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g","caption":"\u6d77\u6597, \u8475"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/kaitoaoi\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/%e6%98%a5%e3%81%aerestcontroller\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=778"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/778\/revisions"}],"predecessor-version":[{"id":44902,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/778\/revisions\/44902"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}