@RequestMapping
@RequestMapping("/app")
public class AppController {
@RequestMapping("/home")
public String index() {
return "home.jsp"
}
} @RequestMaddping可选参数
sprngmvc ant风格
最后更新于
@RequestMapping("/app")
public class AppController {
@RequestMapping("/home")
public String index() {
return "home.jsp"
}
} 最后更新于
@Controller
@RequestMapping("/user")
public class UserController {
@RequestMapping(value = {"/add", "increment"})
public String index() {
return "app";
}
@RequestMapping(value = "/add")
public String add() {
return "add";
}
@RequestMapping("/decrease")
public String decrease() {
return "decrease";
}
}@Controller
@RequestMapping("/user")
public class UserController {
@RequestMapping(value = {"/add", "increment"}, method = RequestMethod.POST)
public String index() {
return "app";
}
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add() {
return "add";
}
@RequestMapping("/decrease", method = RequestMethod.DELETE)
public String decrease() {
return "decrease";
}
}@Controller
@RequestMapping("/user")
public class UserController {
// 必须携带username参数,例如:http://localhost:8080/user/add?username=xxx
@RequestMapping(value = {"/add", "increment"}, method = RequestMethod.POST, params = {"username"})
public String index() {
return "app";
}
// 必须携带username参数,且username的值为zs,例如:http://localhost:8080/user/add?username=zs
@RequestMapping(value = "/add", method = RequestMethod.GET, params = {"username=zs"})
public String add() {
return "add";
}
// 必须携带username参数,且username的值为zs,且age的值不为18,例如:http://localhost:8080/user/add?username=zs&age=18
@RequestMapping(value = "/decrease", method = RequestMethod.DELETE, params = {"username=zs", "age!=18"})
public String decrease() {
return "decrease";
}
// 不能携带name参数
@RequestMapping(value = "/delete", method = RequestMethod.DELETE, params = {"!name"})
public String delete() {
return "delete";
}
}