http://localhost:8080/spring_mvc_test/simple
[color=blue]mapping by path[/color]
http://localhost:8080/spring_mvc_test/mapping/path
[color=blue]mapping by method[/color]
[color=blue]By path,method,and presence of parameter[/color]
http://localhost:8080/spring_mvc_test//mapping/parameter?foo=111
[color=blue]Mapped by path + method + not presence of query parameter!
[/color]
http://localhost:8080/spring_mvc_test//mapping/parameter?foo1=111
[color=blue]Mapped by path + method + presence of header[/color]
[color=blue]Mapped by path + method + not presence header![/color]
http://localhost:8080/spring_mvc_test/notheader
[color=blue]Mapping by regexp![/color]
http://localhost:8080/spring_mvc_test/regexp/ddd
http://localhost:8080/spring_mvc_test/regexp/test
@RequestMapping("simple")
public @ResponseBody String helloWorld() {
String message = "Hello, this is a simple example";
System.out.println(message);
return message;
}
[color=blue]mapping by path[/color]
http://localhost:8080/spring_mvc_test/mapping/path
@RequestMapping("/mapping/path")
public @ResponseBody String mappingByPath() {
String message = "Mapping by path";
return message;
}
[color=blue]mapping by method[/color]
<form action="http://localhost:8080/spring_mvc_test/mapping/method" method="post">
<input type="submit" value="提交"/>
</form>
@RequestMapping(value="/mapping/method", method=RequestMethod.POST)
public @ResponseBody String mappingByMethod() {
String message = "Mapping by Method";
return message;
}
[color=blue]By path,method,and presence of parameter[/color]
http://localhost:8080/spring_mvc_test//mapping/parameter?foo=111
@RequestMapping(value="/mapping/parameter", method=RequestMethod.GET, params="foo")
public @ResponseBody String byParameter() {
String message = "By path,method,and presence of parameter";
return message;
}
[color=blue]Mapped by path + method + not presence of query parameter!
[/color]
http://localhost:8080/spring_mvc_test//mapping/parameter?foo1=111
@RequestMapping(value="/mapping/parameter", method=RequestMethod.GET, params="!foo")
public @ResponseBody String mappedNotParams(){
String message = "Mapped by path + method + not presence of query parameter!";
return message;
}
[color=blue]Mapped by path + method + presence of header[/color]
@RequestMapping(value="/mapping/header", method=RequestMethod.GET, headers="Accept=text/plain")
public @ResponseBody String byHeader() {
String message = "Mapped by path + method + presence of header!";
return message;
}
[color=blue]Mapped by path + method + not presence header![/color]
http://localhost:8080/spring_mvc_test/notheader
@RequestMapping(value="/notheader", method=RequestMethod.GET, headers="!FooHeader")
public @ResponseBody String byHeaderNegation() {
String message = "Mapped by path + method + not presence header!";
return message;
}
[color=blue]Mapping by regexp![/color]
http://localhost:8080/spring_mvc_test/regexp/ddd
http://localhost:8080/spring_mvc_test/regexp/test
@RequestMapping(value="/regexp/*", method=RequestMethod.GET)
public @ResponseBody String regexp() {
String message = "Mapping by regexp!";
return message;
}