Get pathVariable in Aspect - Spring boot

荒凉一梦 提交于 2020-12-13 02:59:23

问题


I want implement an annotation in spring boot. It's required to get path variable and use in annotation.

@PostMapping("/v1/{id}")
    @HasZone(id = "#id")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    fun createCompany( @PathVariable id: String) {
        ....
}
@Target(AnnotationTarget.FUNCTION)
annotation class HasZone(vararg val id: String)
@Before("@annotation(hasZone)")
    fun checkZonePermissions(hasZone: HasZone) {
        println(hasZone.id)
}

I get the parameter in PreAuthorize like this: #id. But in this function, name of the variable path to function as a string.

Where is the wrong thing to do? How can I fixed the problem?

来源:https://stackoverflow.com/questions/60297081/get-pathvariable-in-aspect-spring-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!