Created
July 14, 2014 07:34
-
-
Save panghea/36f4ea1a205e7f5709ce to your computer and use it in GitHub Desktop.
API例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller | |
@RequestMapping(value = "/xxxApi/") | |
public class XxxController extends BaseController { | |
@RequestMapping(value = "list", method = { RequestMethod.GET }) | |
@ResponseBody | |
// 追加要望サイトの一覧を取得するAPI | |
public ResponseEntity<String> list(HttpServletRequest request, Model model) { | |
AddSiteInfoMeta e = AddSiteInfoMeta.get(); | |
// データストアから一覧を取得 | |
List<AddSiteInfo> lists = Datastore.query(AddSiteInfo.class).sortInMemory(e.version.desc).asList(); | |
ObjectMapper objectMapper = new ObjectMapper(); | |
String jsonp = objectMapper.writeValueAsString(lists); | |
HttpHeaders headers = new HttpHeaders(); | |
headers.add("Content-type", "application/json; charset=utf-8"); | |
ResponseEntity<String> entity = new ResponseEntity<String>(jsonp, headers, HttpStatus.OK); | |
return entity; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment