Skip to content

Instantly share code, notes, and snippets.

@learnit-codeit
Created June 19, 2021 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save learnit-codeit/f0ec28a3ab31c5c95ef6359398c179f4 to your computer and use it in GitHub Desktop.
Save learnit-codeit/f0ec28a3ab31c5c95ef6359398c179f4 to your computer and use it in GitHub Desktop.
@Controller
@RequestMapping("/rest1")
public class MyController {
@RequestMapping(value="/getdata", method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
@ResponseBody
public String getMyData() {
JSONObject obj=new JSONObject();
obj.put("name","Anish Antony");
obj.put("age",27);
obj.put("salary",10000);
return obj.toJSONString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment