Make use of new GetMapping and PostMapping annotations
Closes gh-5277
This commit is contained in:
parent
12bd53777e
commit
3348ed5bb3
|
@ -18,8 +18,7 @@ package org.springframework.boot.actuate.endpoint.mvc;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +38,7 @@ public class EndpointMvcAdapter extends AbstractEndpointMvcAdapter<Endpoint<?>>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Object invoke() {
|
public Object invoke() {
|
||||||
return super.invoke();
|
return super.invoke();
|
||||||
|
|
|
@ -26,9 +26,8 @@ import org.springframework.core.env.PropertySource;
|
||||||
import org.springframework.core.env.PropertySources;
|
import org.springframework.core.env.PropertySources;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
@ -49,7 +48,7 @@ public class EnvironmentMvcEndpoint extends EndpointMvcAdapter
|
||||||
super(delegate);
|
super(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/{name:.*}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(value = "/{name:.*}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@HypermediaDisabled
|
@HypermediaDisabled
|
||||||
public Object value(@PathVariable String name) {
|
public Object value(@PathVariable String name) {
|
||||||
|
|
|
@ -22,9 +22,8 @@ import org.springframework.boot.actuate.endpoint.MetricsEndpoint;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ public class MetricsMvcEndpoint extends EndpointMvcAdapter {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/{name:.*}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(value = "/{name:.*}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@HypermediaDisabled
|
@HypermediaDisabled
|
||||||
public Object value(@PathVariable String name) {
|
public Object value(@PathVariable String name) {
|
||||||
|
|
|
@ -23,8 +23,7 @@ import org.springframework.boot.actuate.endpoint.ShutdownEndpoint;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +38,7 @@ public class ShutdownMvcEndpoint extends EndpointMvcAdapter {
|
||||||
super(delegate);
|
super(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@PostMapping
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Override
|
@Override
|
||||||
public Object invoke() {
|
public Object invoke() {
|
||||||
|
|
|
@ -27,8 +27,7 @@ import org.springframework.context.support.StaticApplicationContext;
|
||||||
import org.springframework.mock.web.MockHttpServletRequest;
|
import org.springframework.mock.web.MockHttpServletRequest;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -168,7 +167,7 @@ public class EndpointHandlerMappingTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@PostMapping
|
||||||
public Object invoke() {
|
public Object invoke() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,8 +90,8 @@ import org.springframework.security.oauth2.provider.token.store.InMemoryTokenSto
|
||||||
import org.springframework.test.util.ReflectionTestUtils;
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@ -191,7 +191,8 @@ public class OAuth2AutoConfigurationTests {
|
||||||
EnvironmentTestUtils.addEnvironment(context,
|
EnvironmentTestUtils.addEnvironment(context,
|
||||||
"security.oauth2.client.clientId=client");
|
"security.oauth2.client.clientId=client");
|
||||||
context.refresh();
|
context.refresh();
|
||||||
assertThat(countBeans(context, ClientCredentialsResourceDetails.class)).isEqualTo(1);
|
assertThat(countBeans(context, ClientCredentialsResourceDetails.class))
|
||||||
|
.isEqualTo(1);
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,13 +466,13 @@ public class OAuth2AutoConfigurationTests {
|
||||||
@RestController
|
@RestController
|
||||||
protected static class TestWebApp {
|
protected static class TestWebApp {
|
||||||
|
|
||||||
@RequestMapping(value = "/securedFind", method = RequestMethod.GET)
|
@GetMapping("/securedFind")
|
||||||
@PreAuthorize("#oauth2.hasScope('read')")
|
@PreAuthorize("#oauth2.hasScope('read')")
|
||||||
public String secureFind() {
|
public String secureFind() {
|
||||||
return "You reached an endpoint secured by Spring Security OAuth2";
|
return "You reached an endpoint secured by Spring Security OAuth2";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/securedSave", method = RequestMethod.POST)
|
@PostMapping("/securedSave")
|
||||||
@PreAuthorize("#oauth2.hasScope('write')")
|
@PreAuthorize("#oauth2.hasScope('write')")
|
||||||
public String secureSave() {
|
public String secureSave() {
|
||||||
return "You reached an endpoint secured by Spring Security OAuth2";
|
return "You reached an endpoint secured by Spring Security OAuth2";
|
||||||
|
|
|
@ -49,9 +49,9 @@ import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.validation.BindException;
|
import org.springframework.validation.BindException;
|
||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.servlet.View;
|
import org.springframework.web.servlet.View;
|
||||||
|
@ -263,7 +263,7 @@ public class BasicErrorControllerIntegrationTests {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(path = "/bodyValidation", method = RequestMethod.POST, produces = "application/json")
|
@PostMapping(path = "/bodyValidation", produces = "application/json")
|
||||||
public String bodyValidation(@Valid @RequestBody DummyBody body) {
|
public String bodyValidation(@Valid @RequestBody DummyBody body) {
|
||||||
return body.content;
|
return body.content;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class SampleController {
|
public class SampleController {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String hello() {
|
public String hello() {
|
||||||
return "Hello World";
|
return "Hello World";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class SampleController {
|
public class SampleController {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String hello() {
|
public String hello() {
|
||||||
return "Hello World";
|
return "Hello World";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class SampleController {
|
public class SampleController {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String hello() {
|
public String hello() {
|
||||||
return "Hello World";
|
return "Hello World";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,6 +21,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, String> helloWorld() {
|
public Map<String, String> helloWorld() {
|
||||||
return Collections.singletonMap("message",
|
return Collections.singletonMap("message",
|
||||||
|
|
|
@ -24,13 +24,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@Controller
|
@Controller
|
||||||
public class SampleActuatorUiApplication {
|
public class SampleActuatorUiApplication {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String home(Map<String, Object> model) {
|
public String home(Map<String, Object> model) {
|
||||||
model.put("message", "Hello World");
|
model.put("message", "Hello World");
|
||||||
model.put("title", "Hello Home");
|
model.put("title", "Hello Home");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -27,8 +27,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Description;
|
import org.springframework.context.annotation.Description;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -38,14 +39,14 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, String> hello() {
|
public Map<String, String> hello() {
|
||||||
return Collections.singletonMap("message",
|
return Collections.singletonMap("message",
|
||||||
this.helloWorldService.getHelloMessage());
|
this.helloWorldService.getHelloMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/", method = RequestMethod.POST)
|
@PostMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, Object> olleh(@Validated Message message) {
|
public Map<String, Object> olleh(@Validated Message message) {
|
||||||
Map<String, Object> model = new LinkedHashMap<String, Object>();
|
Map<String, Object> model = new LinkedHashMap<String, Object>();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2013 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,7 +21,7 @@ import sample.data.jpa.service.CityService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -30,7 +30,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CityService cityService;
|
private CityService cityService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,13 +22,13 @@ import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class MyController {
|
public class MyController {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public ModelAndView get(HttpSession session) {
|
public ModelAndView get(HttpSession session) {
|
||||||
Object sessionVar = session.getAttribute("var");
|
Object sessionVar = session.getAttribute("var");
|
||||||
if (sessionVar == null) {
|
if (sessionVar == null) {
|
||||||
|
|
|
@ -28,9 +28,9 @@ import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/customers")
|
@RequestMapping("/customers")
|
||||||
|
@ -46,7 +46,7 @@ public class CustomerController {
|
||||||
this.entityLinks = entityLinks;
|
this.entityLinks = entityLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
HttpEntity<Resources<Customer>> showCustomers() {
|
HttpEntity<Resources<Customer>> showCustomers() {
|
||||||
Resources<Customer> resources = new Resources<Customer>(
|
Resources<Customer> resources = new Resources<Customer>(
|
||||||
this.repository.findAll());
|
this.repository.findAll());
|
||||||
|
@ -54,7 +54,7 @@ public class CustomerController {
|
||||||
return new ResponseEntity<Resources<Customer>>(resources, HttpStatus.OK);
|
return new ResponseEntity<Resources<Customer>>(resources, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
HttpEntity<Resource<Customer>> showCustomer(@PathVariable Long id) {
|
HttpEntity<Resource<Customer>> showCustomer(@PathVariable Long id) {
|
||||||
Resource<Customer> resource = new Resource<Customer>(this.repository.findOne(id));
|
Resource<Customer> resource = new Resource<Customer>(this.repository.findOne(id));
|
||||||
resource.add(this.entityLinks.linkToSingleResource(Customer.class, id));
|
resource.add(this.entityLinks.linkToSingleResource(Customer.class, id));
|
||||||
|
|
|
@ -21,7 +21,7 @@ import sample.hibernate4.service.CityService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -30,7 +30,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CityService cityService;
|
private CityService cityService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,7 +20,7 @@ import sample.jetty.ssl.service.HelloWorldService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -29,7 +29,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return this.helloWorldService.getHelloMessage();
|
return this.helloWorldService.getHelloMessage();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2013 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,7 +20,7 @@ import sample.jetty.service.HelloWorldService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -29,7 +29,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return this.helloWorldService.getHelloMessage();
|
return this.helloWorldService.getHelloMessage();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,7 +20,7 @@ import sample.jetty8.ssl.service.HelloWorldService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -29,7 +29,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return this.helloWorldService.getHelloMessage();
|
return this.helloWorldService.getHelloMessage();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,7 +20,7 @@ import sample.jetty8.service.HelloWorldService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -29,7 +29,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return this.helloWorldService.getHelloMessage();
|
return this.helloWorldService.getHelloMessage();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,7 +20,7 @@ import sample.jetty93.service.HelloWorldService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -29,7 +29,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return this.helloWorldService.getHelloMessage();
|
return this.helloWorldService.getHelloMessage();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,7 +24,7 @@ import sample.jpa.repository.NoteRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -33,7 +33,7 @@ public class IndexController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private NoteRepository noteRepository;
|
private NoteRepository noteRepository;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public ModelAndView index() {
|
public ModelAndView index() {
|
||||||
List<Note> notes = this.noteRepository.findAll();
|
List<Note> notes = this.noteRepository.findAll();
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package sample.jndi;
|
package sample.jndi;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -31,7 +31,7 @@ public class WebController {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String hello() {
|
public String hello() {
|
||||||
System.out.println("Count is " + this.repository.count());
|
System.out.println("Count is " + this.repository.count());
|
||||||
this.service.createAccountAndNotify("josh");
|
this.service.createAccountAndNotify("josh");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -25,8 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.actuate.metrics.GaugeService;
|
import org.springframework.boot.actuate.metrics.GaugeService;
|
||||||
import org.springframework.context.annotation.Description;
|
import org.springframework.context.annotation.Description;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -39,7 +38,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GaugeService gauges;
|
private GaugeService gauges;
|
||||||
|
|
||||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, String> hello() {
|
public Map<String, String> hello() {
|
||||||
this.gauges.submit("timer.test.value", Math.random() * 1000 + 1000);
|
this.gauges.submit("timer.test.value", Math.random() * 1000 + 1000);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,8 +24,7 @@ import org.hibernate.validator.constraints.NotBlank;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Description;
|
import org.springframework.context.annotation.Description;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -35,7 +34,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, String> hello() {
|
public Map<String, String> hello() {
|
||||||
return Collections.singletonMap("message",
|
return Collections.singletonMap("message",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,8 +24,7 @@ import org.hibernate.validator.constraints.NotBlank;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Description;
|
import org.springframework.context.annotation.Description;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -35,7 +34,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, String> hello() {
|
public Map<String, String> hello() {
|
||||||
return Collections.singletonMap("message",
|
return Collections.singletonMap("message",
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
|
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
|
||||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +99,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
@RestController
|
@RestController
|
||||||
public class SampleSecureOAuth2Application {
|
public class SampleSecureOAuth2Application {
|
||||||
|
|
||||||
@RequestMapping("/user")
|
@GetMapping("/user")
|
||||||
public Principal user(Principal user) {
|
public Principal user(Principal user) {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,13 +20,13 @@ import java.util.UUID;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class HelloRestController {
|
public class HelloRestController {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
String uid(HttpSession session) {
|
String uid(HttpSession session) {
|
||||||
UUID uid = (UUID) session.getAttribute("uid");
|
UUID uid = (UUID) session.getAttribute("uid");
|
||||||
if (uid == null) {
|
if (uid == null) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,7 +20,7 @@ import sample.testng.service.HelloWorldService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -29,7 +29,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return this.helloWorldService.getHelloMessage();
|
return this.helloWorldService.getHelloMessage();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
@ -33,7 +34,7 @@ public class WelcomeController {
|
||||||
@Value("${application.message:Hello World}")
|
@Value("${application.message:Hello World}")
|
||||||
private String message = "Hello World";
|
private String message = "Hello World";
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String welcome(Map<String, Object> model) {
|
public String welcome(Map<String, Object> model) {
|
||||||
model.put("time", new Date());
|
model.put("time", new Date());
|
||||||
model.put("message", this.message);
|
model.put("message", this.message);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
package sample.tomcat.multiconnector.web;
|
package sample.tomcat.multiconnector.web;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class SampleController {
|
public class SampleController {
|
||||||
|
|
||||||
@RequestMapping("/hello")
|
@GetMapping("/hello")
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return "hello";
|
return "hello";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,13 +17,13 @@
|
||||||
package sample.tomcat.ssl.web;
|
package sample.tomcat.ssl.web;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class SampleController {
|
public class SampleController {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return "Hello, world";
|
return "Hello, world";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2013 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,7 +20,7 @@ import sample.tomcat.service.HelloWorldService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -29,7 +29,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return this.helloWorldService.getHelloMessage();
|
return this.helloWorldService.getHelloMessage();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,7 +21,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class WelcomeController {
|
public class WelcomeController {
|
||||||
|
@ -29,7 +29,7 @@ public class WelcomeController {
|
||||||
@Value("${application.message:Hello World}")
|
@Value("${application.message:Hello World}")
|
||||||
private String message = "Hello World";
|
private String message = "Hello World";
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String welcome(Map<String, Object> model) {
|
public String welcome(Map<String, Object> model) {
|
||||||
model.put("time", new Date());
|
model.put("time", new Date());
|
||||||
model.put("message", this.message);
|
model.put("message", this.message);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,7 +20,7 @@ import sample.undertow.ssl.service.HelloWorldService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -29,7 +29,7 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return this.helloWorldService.getHelloMessage();
|
return this.helloWorldService.getHelloMessage();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,7 +21,7 @@ import java.util.concurrent.Callable;
|
||||||
import sample.undertow.service.HelloWorldService;
|
import sample.undertow.service.HelloWorldService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -30,12 +30,12 @@ public class SampleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String helloWorld() {
|
public String helloWorld() {
|
||||||
return this.helloWorldService.getHelloMessage();
|
return this.helloWorldService.getHelloMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/async")
|
@GetMapping("/async")
|
||||||
public Callable<String> helloWorldAsync() {
|
public Callable<String> helloWorldAsync() {
|
||||||
return new Callable<String>() {
|
return new Callable<String>() {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
|
|
||||||
package sample.war;
|
package sample.war;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class MyController {
|
public class MyController {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String hello() {
|
public String hello() {
|
||||||
return "Hello World!";
|
return "Hello World!";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,7 +21,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class WelcomeController {
|
public class WelcomeController {
|
||||||
|
@ -29,7 +29,7 @@ public class WelcomeController {
|
||||||
@Value("${application.message:Hello World}")
|
@Value("${application.message:Hello World}")
|
||||||
private String message = "Hello World";
|
private String message = "Hello World";
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String welcome(Map<String, Object> model) {
|
public String welcome(Map<String, Object> model) {
|
||||||
model.put("time", new Date());
|
model.put("time", new Date());
|
||||||
model.put("message", this.message);
|
model.put("message", this.message);
|
||||||
|
|
|
@ -28,10 +28,11 @@ import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.validation.FieldError;
|
import org.springframework.validation.FieldError;
|
||||||
import org.springframework.validation.ObjectError;
|
import org.springframework.validation.ObjectError;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
@ -45,23 +46,23 @@ public class MessageController {
|
||||||
this.messageRepository = messageRepository;
|
this.messageRepository = messageRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping
|
@GetMapping
|
||||||
public ModelAndView list() {
|
public ModelAndView list() {
|
||||||
Iterable<Message> messages = this.messageRepository.findAll();
|
Iterable<Message> messages = this.messageRepository.findAll();
|
||||||
return new ModelAndView("messages/list", "messages", messages);
|
return new ModelAndView("messages/list", "messages", messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("{id}")
|
@GetMapping("{id}")
|
||||||
public ModelAndView view(@PathVariable("id") Message message) {
|
public ModelAndView view(@PathVariable("id") Message message) {
|
||||||
return new ModelAndView("messages/view", "message", message);
|
return new ModelAndView("messages/view", "message", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(params = "form", method = RequestMethod.GET)
|
@GetMapping(params = "form")
|
||||||
public String createForm(@ModelAttribute Message message) {
|
public String createForm(@ModelAttribute Message message) {
|
||||||
return "messages/form";
|
return "messages/form";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@PostMapping
|
||||||
public ModelAndView create(@Valid Message message, BindingResult result,
|
public ModelAndView create(@Valid Message message, BindingResult result,
|
||||||
RedirectAttributes redirect) {
|
RedirectAttributes redirect) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,6 +21,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -29,7 +30,7 @@ public class WelcomeController {
|
||||||
@Value("${application.message:Hello World}")
|
@Value("${application.message:Hello World}")
|
||||||
private String message = "Hello World";
|
private String message = "Hello World";
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String welcome(Map<String, Object> model) {
|
public String welcome(Map<String, Object> model) {
|
||||||
model.put("time", new Date());
|
model.put("time", new Date());
|
||||||
model.put("message", this.message);
|
model.put("message", this.message);
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter {
|
||||||
@Controller
|
@Controller
|
||||||
protected static class HomeController {
|
protected static class HomeController {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
@Secured("ROLE_ADMIN")
|
@Secured("ROLE_ADMIN")
|
||||||
public String home(Map<String, Object> model) {
|
public String home(Map<String, Object> model) {
|
||||||
model.put("message", "Hello World");
|
model.put("message", "Hello World");
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Map;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ public class WelcomeController {
|
||||||
@Value("${application.message:Hello World}")
|
@Value("${application.message:Hello World}")
|
||||||
private String message = "Hello World";
|
private String message = "Hello World";
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String welcome(Map<String, Object> model) {
|
public String welcome(Map<String, Object> model) {
|
||||||
model.put("time", new Date());
|
model.put("time", new Date());
|
||||||
model.put("message", this.message);
|
model.put("message", this.message);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.springframework.security.config.annotation.authentication.builders.Au
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
@ -36,7 +37,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
||||||
@Controller
|
@Controller
|
||||||
public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter {
|
public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String home(Map<String, Object> model) {
|
public String home(Map<String, Object> model) {
|
||||||
model.put("message", "Hello World");
|
model.put("message", "Hello World");
|
||||||
model.put("title", "Hello Home");
|
model.put("title", "Hello Home");
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.springframework.security.config.annotation.authentication.builders.Au
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
@ -39,7 +40,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
||||||
@Controller
|
@Controller
|
||||||
public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter {
|
public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String home(Map<String, Object> model) {
|
public String home(Map<String, Object> model) {
|
||||||
model.put("message", "Hello World");
|
model.put("message", "Hello World");
|
||||||
model.put("title", "Hello Home");
|
model.put("title", "Hello Home");
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.springframework.security.config.annotation.authentication.builders.Au
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
@ -36,7 +37,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
||||||
@Controller
|
@Controller
|
||||||
public class SampleWebSecureApplication extends WebMvcConfigurerAdapter {
|
public class SampleWebSecureApplication extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String home(Map<String, Object> model) {
|
public String home(Map<String, Object> model) {
|
||||||
model.put("message", "Hello World");
|
model.put("message", "Hello World");
|
||||||
model.put("title", "Hello Home");
|
model.put("title", "Hello Home");
|
||||||
|
|
|
@ -23,10 +23,11 @@ import sample.web.ui.MessageRepository;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
@ -44,23 +45,23 @@ public class MessageController {
|
||||||
this.messageRepository = messageRepository;
|
this.messageRepository = messageRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping
|
@GetMapping
|
||||||
public ModelAndView list() {
|
public ModelAndView list() {
|
||||||
Iterable<Message> messages = this.messageRepository.findAll();
|
Iterable<Message> messages = this.messageRepository.findAll();
|
||||||
return new ModelAndView("messages/list", "messages", messages);
|
return new ModelAndView("messages/list", "messages", messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("{id}")
|
@GetMapping("{id}")
|
||||||
public ModelAndView view(@PathVariable("id") Message message) {
|
public ModelAndView view(@PathVariable("id") Message message) {
|
||||||
return new ModelAndView("messages/view", "message", message);
|
return new ModelAndView("messages/view", "message", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(params = "form", method = RequestMethod.GET)
|
@GetMapping(params = "form")
|
||||||
public String createForm(@ModelAttribute Message message) {
|
public String createForm(@ModelAttribute Message message) {
|
||||||
return "messages/form";
|
return "messages/form";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@PostMapping
|
||||||
public ModelAndView create(@Valid Message message, BindingResult result,
|
public ModelAndView create(@Valid Message message, BindingResult result,
|
||||||
RedirectAttributes redirect) {
|
RedirectAttributes redirect) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
|
@ -76,14 +77,14 @@ public class MessageController {
|
||||||
throw new RuntimeException("Expected exception in controller");
|
throw new RuntimeException("Expected exception in controller");
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "delete/{id}")
|
@GetMapping(value = "delete/{id}")
|
||||||
public ModelAndView delete(@PathVariable("id") Long id) {
|
public ModelAndView delete(@PathVariable("id") Long id) {
|
||||||
this.messageRepository.deleteMessage(id);
|
this.messageRepository.deleteMessage(id);
|
||||||
Iterable<Message> messages = this.messageRepository.findAll();
|
Iterable<Message> messages = this.messageRepository.findAll();
|
||||||
return new ModelAndView("messages/list", "messages", messages);
|
return new ModelAndView("messages/list", "messages", messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "modify/{id}", method = RequestMethod.GET)
|
@GetMapping(value = "modify/{id}")
|
||||||
public ModelAndView modifyForm(@PathVariable("id") Message message) {
|
public ModelAndView modifyForm(@PathVariable("id") Message message) {
|
||||||
return new ModelAndView("messages/form", "message", message);
|
return new ModelAndView("messages/form", "message", message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,7 +21,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class WelcomeController {
|
public class WelcomeController {
|
||||||
|
@ -29,7 +29,7 @@ public class WelcomeController {
|
||||||
@Value("${application.message:Hello World}")
|
@Value("${application.message:Hello World}")
|
||||||
private String message = "Hello World";
|
private String message = "Hello World";
|
||||||
|
|
||||||
@RequestMapping("/")
|
@GetMapping("/")
|
||||||
public String welcome(Map<String, Object> model) {
|
public String welcome(Map<String, Object> model) {
|
||||||
model.put("time", new Date());
|
model.put("time", new Date());
|
||||||
model.put("message", this.message);
|
model.put("message", this.message);
|
||||||
|
|
Loading…
Reference in New Issue