我在Spring项目中有一个这样的控制器:
@Controller
@RequestMapping(value="mapping_one")
public class AcessoController {
@RequestMapping(value="mapping_two")
public ModelAndView mapping_two() {
ModelAndView mav = new ModelAndView();
mav.setViewName("view");
return mav;
}
}
并且用户通知的网址也是这样的:
http://webapp/mapping_one/mapping_two/some_string_here/
有没有办法从上面的控制器中捕获方法some_string_here
内的mapping_two
(返回值的类型可能不同)?
答案 0 :(得分:2)
您可以使用@PathVariable注释:
@RequestMapping(value = "mapping_two/{theString}")
public ModelAndView mappingTwo(@PathVariable String theString) {
...
}