相关疑难解决方法(0)

只获取@Requestmapping的通配符部分

我在控制器操作上使用通配符映射,并希望通过通配符获得字符串匹配.我怎么能以正确的方式做到这一点?不使用子串等

@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


        // ...
    }

}|
Run Code Online (Sandbox Code Playgroud)

spring-mvc

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

spring-mvc ×1