Spring MVC 有一种方法可以调用方法排除一些url

6jygbczu  于 7个月前  发布在  Spring
关注(0)|答案(1)|浏览(78)

我需要调用这个方法时,网址不包含字符“API”。我是新的Spring,我不知道我是否可以这样做。该方法是

@Controller 
public class RouterController { 
     //here I need to call method when the url doesn't contains the word "api"
  @RequestMapping({"/api*"}) 
    public String app() { 
   ...
  } 
}

有人能帮我吗?

j13ufse2

j13ufse21#

您可以尝试使用:^(?!API$).*$

@Controller 
public class RouterController { 
     //here I need to call method when the url doesn't contains the word "api"
  @RequestMapping({"/^(?!api$).*$"}) 
    public String app() { 
   ...
  } 
}

相关问题