为什么一定要判断mappingInfo是否为空
我不判断mappingInfo是否为空,springboot在启动的时候就会报错:
@Override protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) { RequestMappingInfo mappingInfo = super.getMappingForMethod(method, handlerType); String prefix = this.getPrefix(handlerType); RequestMappingInfo prefixMappingInfo = RequestMappingInfo.paths(prefix).build(); return prefixMappingInfo.combine(mappingInfo); }
但判断mappingInfo是否为空,就不会报错:
@Override protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) { RequestMappingInfo mappingInfo = super.getMappingForMethod(method, handlerType); if(mappingInfo != null){ String prefix = this.getPrefix(handlerType); RequestMappingInfo prefixMappingInfo = RequestMappingInfo.paths(prefix).build(); return prefixMappingInfo.combine(mappingInfo); } return null; }
请问老师,这是什么原因?
76
收起
正在回答 回答被采纳积分+1
2回答
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星