package cn.wycclub.handlers;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.stereotype.Controller;
@Controller
@RequestMapping("/test")
public class MyController {
@RequestMapping("/third*.do") //资源名称必须以third开头
public ModelAndView doThird(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception {
ModelAndView mv = new ModelAndView();
mv.addObject("message","doThird");
mv.setViewName("/WEB-INF/jsp/welcome.jsp");
return mv;
}
@RequestMapping("/*fourth.do")//资源名称必须以fourth结尾
public ModelAndView doFourth(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception {
ModelAndView mv = new ModelAndView();
mv.addObject("message","doFourth");
mv.setViewName("/WEB-INF/jsp/welcome.jsp");
return mv;
}
@RequestMapping("/*/fifth.do") //路径级数的绝对匹配,既要求在test与fifth.do之间必须有一级路径
public ModelAndView doFifth(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception {
ModelAndView mv = new ModelAndView();
mv.addObject("message","doFifth");
mv.setViewName("/WEB-INF/jsp/welcome.jsp");
return mv;
}
@RequestMapping("/**/sixth.do") //要求在test与sixth.do之间可以包含零到多级路径
public ModelAndView doSixth(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception {
ModelAndView mv = new ModelAndView();
mv.addObject("message","doSixth");
mv.setViewName("/WEB-INF/jsp/welcome.jsp");
return mv;
}
}
SpringMVC4 学习笔记(九) 【通配符】
最新推荐文章于 2018-01-29 14:45:58 发布