Java代码
- @RequestMapping(value="/departments")
- public String simplePattern(){
- System.out.println("simplePattern method was called");
- return "someResult";
- }
Java代码
- @RequestMapping(value="/departments")
- public String findDepatment(
- @RequestParam("departmentId") String departmentId){
- System.out.println("Find department with ID: " + departmentId);
- return "someResult";
- }
Java代码
- @RequestMapping(value="/departments/{departmentId}")
- public String findDepatment(@PathVariable String departmentId){
- System.out.println("Find department with ID: " + departmentId);
- return "someResult";
- }
Java代码
- @RequestMapping(value="/departments/{departmentId}")
- public String findDepatmentAlternative(
- @PathVariable("departmentId") String someDepartmentId){
- System.out.println("Find department with ID: " + someDepartmentId);
- return "someResult";
- }
Java代码
- @RequestMapping(value="/departments/{departmentId}/employees/{employeeId}")
- public String findEmployee(
- @PathVariable String departmentId,
- @PathVariable String employeeId){
- System.out.println("Find employee with ID: " + employeeId +
- " from department: " + departmentId);
- return "someResult";
- }
Java代码
- @RequestMapping(value="/{textualPart:[a-z-]+}.{numericPart:[\\d]+}")
- public String regularExpression(
- @PathVariable String textualPart,
- @PathVariable String numericPart){
- System.out.println("Textual part: " + textualPart +
- ", numeric part: " + numericPart);
- return "someResult";
- }
Textual part: sometext, numeric part: 123.
转载: