有什么办法全局满足跨域,并且某些方法在加其他过滤器的时候不会覆盖跨域过滤器,比如
仍然能够用CrossOriginsFilter下还能加其他过滤器,难道只能用
@Filters({@By(type = CrossOriginsFilter.class,args = {"ioc:crossFilter"}),@By(type = AccessTokenFilter.class, args = {"ioc:tokenFilter"})})这种写法,如此岂不是每个方法都要这样做???,我只想让所有方法都能支持跨域,而有些方法再累加其他过滤器。
@Filters(@By(type = AccessTokenFilter.class, args = {"ioc:tokenFilter"}))
@At("/logout")
public Rs doLogout(){
Rs rs = new Rs();
rs.setCode(Rs.SUCCESS);
rs.setMsg("logout");
return rs;
}
}
@Inject
UserServiceImpl userService;
@Filters(@By(type = CrossOriginsFilter.class,args = {"ioc:crossFilter"}))
@At("/login")
public Rs dologin(@Param("username") String username, @Param("password") String password) {
Rs<UserDb> rs = new Rs<UserDb>();
if(Strings.isBlank(username) || Strings.isBlank(password)){
rs.setCode(Rs.FAIL);
rs.setMsg("用户名或密码不能为空");
return rs;
}
UserDb exist = userService.fetch(username);