Skip to content

Instantly share code, notes, and snippets.

@Component
public class JwtFilter extends OncePerRequestFilter {
@Autowired
private UserRepository userRepository;
@Autowired
private JWTUtils jwtUtils;
@Override
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "ec2:*",
"Effect": "Allow",
"Resource": "*"
},
{
"Effect": "Allow",
@Controller
@RequestMapping("/rest")
public class MyController {
@GetMapping("/get")
public ResponseEntity<String> getExample() {
return new ResponseEntity<String>("Get Example", HttpStatus.OK);
}
@GetMapping("/getvar/{id}")
public ResponseEntity<String> getExampleWithVariable(@PathVariable String id){
return new ResponseEntity<String>("Get With Variable Example" +id,HttpStatus.OK); }
@RestController
@RequestMapping("/rest")
public class MyRestController {
@RequestMapping(value="/requestparamexample", method = RequestMethod.GET)
public ResponseEntity<String> getRequestParmParam(@RequestParam("value") String value) {
System.out.println("Request Param Value: "+value);
return new ResponseEntity<String>(value,HttpStatus.OK);
}
}
@RestController
@RequestMapping("/rest")
public class MyRestController {
@RequestMapping(value="/pathparamexample/{value}", method = RequestMethod.GET)
public ResponseEntity<String> getPathParam(@PathVariable String value) {
System.out.println("Path Variable Value: "+value);
return new ResponseEntity<String>(value,HttpStatus.OK);
}
}
@RestController
@RequestMapping("/user")
public class UserController {
@RequestMapping(value={"/find", "/search*","/get/*","**/findall"}, method = RequestMethod.GET)
public String findAllUsers() {
return "GettingUsers";
}
}
@RestController
@RequestMapping("/user")
public class UserController {
@RequestMapping(value="/find", method = RequestMethod.GET)
public void findAllUsers() {
/**
* Adding user logic
*/
}
@RestController
@RequestMapping("/rest")
public class MyRestController {
@RequestMapping(value="/getdata", method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
public String getMyData() {
JSONObject obj=new JSONObject();
obj.put("name","Anish Antony");
obj.put("age",27);
obj.put("salary",10000);
return obj.toJSONString();
@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);
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Controller {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any (or empty String otherwise)