您的位置:首页 > 移动开发

@RequestMapping 细节影响访问路径是否可以访问

2013-10-31 14:23 429 查看
@RequestMapping可以用在类上,也可以用在方法上,但是如果后面跟上method,即:@RequestMapping(value="/account" , method = RequestMethod.GET),若将此用在类上则无法访问,报(警告: No mapping found for HTTP request with URI [/spring_frame/account] in DispatcherServlet with name 'spring')的错误,而如果将@RequestMapping(value="/account"
, method = RequestMethod.GET),用在方法上,则可以正常访问。而若将@RequestMapping(value="/account" , method = RequestMethod.GET)拆分为两句,将@RequestMapping("/account")用在类上,再将@RequestMapping( method = RequestMethod.GET)用在方法上,则也是可以正常访问的,因此虽然:@RequestMapping既可以用在类上也可以用在方法上,但是若带上参数的传输方式,建议最好用在方法上,或拆分注解。

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐