大佬教程收集整理的这篇文章主要介绍了仅获取@Requestmapping的通配符部分,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
看来问题已经在这里解决了:Spring 3requestMapPing:尽管接受的答案回答问题,但仍获取路径值。一个建议的解决方案(这个解决方案)似乎有效,因为我刚刚尝试过:
@Controller
@requestMapPing(value = "/propertIEs")
public class PropertIEsController {
@requestMapPing(value = "/**", method=requestMethod.GET)
public voID getFoo(final httpServletrequest request) {
String path = (String) request.getAttribute(
HandlerMapPing.PATH_WITHIN_HANDLER_MAPPing_ATTRIBUTE);
String bestMatchPattern = (String ) request.getAttribute(HandlerMapPing.bEST_MATCHING_PATTERN_ATTRIBUTE);
AntPathMatcher apm = new AntPathMatcher();
String finalPath = apm.extractPathWithinPattern(bestMatchPattern, path);
// on "/propertIEs/foo/bar", finalPath contains "foo/bar"
}
}
我建议您对未接受的答案进行投票,即使要达到可接受的答案的分数还有很长的路要走。从在另一个线程上接受答案的时间到现在(因为不可能有一个错误的答案达到如此高的分数)之间的规格发生了变化,我不会感到惊讶。
我在控制器操作上使用了通配符映射,并且想让通配符匹配字符串。我该如何正确做呢?不使用子串等
@Controller
@requestMapping(value = "/properties")
public class PropertiesController {
@requestMapping(value = "/**",method=requestMethod.GET)
public void getFoo() {
String key = (String) request. getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
// returns "/properties/foo/bar" ...
// I want only "foo/bar" part
// ...
}
}|
以上是大佬教程为你收集整理的仅获取@Requestmapping的通配符部分全部内容,希望文章能够帮你解决仅获取@Requestmapping的通配符部分所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。