HelloController.java
@RestController
@RequestMapping(value = "/hello", method = {
// RequestMethod.POST,
// RequestMethod.GET
})
public class HelloController {
/**
* http://127.0.0.1/hello
*/
@RequestMapping
public String hello() {
return "hello, springboot";
}
/**
* http://127.0.0.1/hello/index
*/
@RequestMapping(value = "/index", method = {
RequestMethod.POST,
RequestMethod.GET
})
public String index() {
return "index";
}
/**
* http://127.0.0.1/hello/test
* http://127.0.0.1/hello/test1
* http://127.0.0.1/hello/test2
* http://127.0.0.1/hello/test3
*/
@RequestMapping(value = {
"/test",
"/test1",
"/test2",
"/test3",
})
public String test() {
return "多URL映射测试";
}
/**
* http://127.0.0.1/hello/get
*/
@RequestMapping(value = "/get", method = RequestMethod.GET)
public String get() {
return "只允许 get";
}
/**
* http://127.0.0.1/hello/post
*/
@RequestMapping(value = "/post", method = RequestMethod.POST)
public String post() {
return "只允许 post";
}
}