spring_mvc(2)Mapping Request

spring_mvc(二)Mapping Request
http://localhost:8080/spring_mvc_test/simple
@RequestMapping("simple")
public @ResponseBody String helloWorld() { 
    String message = "Hello, this is a simple example";
    System.out.println(message);
    return message;
}


mapping by path

http://localhost:8080/spring_mvc_test/mapping/path
@RequestMapping("/mapping/path")
public @ResponseBody String mappingByPath() {
     String message = "Mapping by path";
     return message;
}


mapping by method
<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;
}


By path,method,and presence of parameter

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;
}


Mapped by path + method + not presence of query parameter!


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;
}


Mapped by path + method + presence of header
@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;
}


Mapped by path + method + not presence header!

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;
}


Mapping by regexp!

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;
}