我有一个控制器,方法如下:
@Controller
@RequestMapping(value = "/employee/**")
public class EmployeeInfoController{
@RequestMapping(method = RequestMethod.GET)
public ModelAndView getEmployeeInfoCriteria(@ModelAttribute("employeeInfoParam") EmployeeInfoParam employeeInfoParam) {
.....
}
@RequestMapping(value = "/details/{empId}", method = RequestMethod.GET)
public ModelAndView getEmployeeDetailsById(@PathVariable String empId) {
......
}
}
我希望每当我出现时/application/employee/
,它就会显示搜索页面。但是它没有显示员工详细信息页面,当我提交请求时/application/emp/details/101
,它是搜索页面而不是详细信息页面。日志显示如下:
09:45:20,937 INFO [STDOUT] DEBUG [RequestMappingHandlerMapping:229] - Looking up handler method for path /employee/details/400000000022161
09:45:20,938 INFO [STDOUT] TRACE [RequestMappingHandlerMapping:267] - Found 2 matching mapping(s) for [/employee/details/400000000022161] : [{[/employee/**],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}, {[/employee/**/details/{empId}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}]
09:45:20,939 INFO [STDOUT] DEBUG [RequestMappingHandlerMapping:234] - Returning handler method [public org.springframework.web.servlet.ModelAndView com.application.web.controller.EmployeeInfoController.getEmployeeInfoCriteria(com.application.web.form.EmployeeInfoParam)]
我的理解是,如果我不提及任何子网址来代替**(在类级别),它将使用getEmployeeInfoCriteria
ie /application/employee/
。如果我提到一个子网址,例如/application/employee/details/1001
,它将由处理getEmployeeDetailsById
。我在这里想念什么?
在类级别的请求映射中无需使用**,只需使用
@RequestMapping(value = "/employee/")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句