如果您对春季启动:accessDeniedHandler不起作用感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于春季启动:accessDeniedHandler不起作用的详细
如果您对春季启动:accessDeniedHandler不起作用感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于春季启动:accessDeniedHandler不起作用的详细内容,我们还将为您解答accessdeniedhandler是干嘛的的相关问题,并且为您提供关于AccessDenied错误解决方法、android – handler.postDelayed在IntentService的onHandleIntent方法中不起作用、Android10+ FileNotFoundException: open failed: EACCES (Permission denied)、Android:FaceDetector不起作用. findface总是检测到零面;的有价值信息。
本文目录一览:- 春季启动:accessDeniedHandler不起作用(accessdeniedhandler是干嘛的)
- AccessDenied错误解决方法
- android – handler.postDelayed在IntentService的onHandleIntent方法中不起作用
- Android10+ FileNotFoundException: open failed: EACCES (Permission denied)
- Android:FaceDetector不起作用. findface总是检测到零面;
春季启动:accessDeniedHandler不起作用(accessdeniedhandler是干嘛的)
我有以下Spring Security配置:
@Configuration@EnableWebSecuritypublic class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers("/api/private/**", "/app/**").authenticated(); http.csrf().disable(); http.logout().logoutSuccessUrl("/"); http.exceptionHandling().accessDeniedPage("/403"); //.accessDeniedHandler(accessDeniedHandler); }}
我期望以下逻辑:未经身份验证的用户将被重定向到/403
。Spring会显示默认的Tomcat
403页面,而不是该页面。我也尝试过自定义,accessDeniedHandler
尽管没有成功。
如何在访问失败时实施自定义逻辑?
答案1
小编典典AccessDeniedHandler仅适用于经过身份验证的用户。未经身份验证的用户的默认行为是重定向到登录页面(或适用于所使用的身份验证机制的任何内容)。
如果要更改,则需要配置AuthenticationEntryPoint
,当未经身份验证的用户尝试访问受保护的资源时会调用。您应该可以使用
http.exceptionHandling().authenticationEntryPoint(...)
而不是你所拥有的。有关更多详细信息,请查看API文档。
AccessDenied错误解决方法
accessdenied错误解决方法有:1、检查权限;2、更改权限;3、访问控制列表;4、检查文件或文件夹的所有权;5、检查防火墙设置;6、重启资源;7、更新驱动程序;8、检查系统错误。
AccessDenied错误通常是由于权限不足或访问被拒绝而导致的。以下是一些可能的解决方法:
1、检查权限:确保你具有访问所需资源的权限。例如,如果你在尝试访问文件或文件夹时遇到AccessDenied错误,请确保你具有对该文件或文件夹的读/写/执行权限。
2、更改权限:如果权限不足,你可以尝试更改权限。例如,在Windows系统中,你可以右键单击文件或文件夹,选择“属性”,然后切换到“安全”选项卡,根据需要更改权限。
3、访问控制列表(ACL):检查访问控制列表(ACL),确保你所在的用户或组被授权访问该资源。你可以在Windows系统中使用命令行工具(如Cacls或Set-ACL)来查看和修改ACL。
4、检查文件或文件夹的所有权:确保你具有文件或文件夹的所有权。你可以在Windows系统中使用命令行工具(如Take-Ownership)来更改文件或文件夹的所有者。
5、检查防火墙设置:确保你的防火墙设置允许你访问所需的资源。如果你在尝试访问网络资源时遇到AccessDenied错误,请检查你的防火墙设置。
6、重启资源:如果访问的资源正在被其他程序或进程使用,请尝试重新启动该资源。例如,在Windows系统中,你可以尝试重新启动文件或文件夹。
7、更新驱动程序:确保你的驱动程序已更新到最新版本。过时的驱动程序可能导致AccessDenied错误。
8、检查系统错误:如果上述方法都无法解决问题,请检查系统错误日志,以获取更多关于AccessDenied错误的详细信息。这将有助于诊断问题并找到适当的解决方案。
请注意,这些解决方法可能因操作系统和具体环境而异。根据你的系统和你遇到的问题,尝试采用适当的方法来解决问题。
以上就是AccessDenied错误解决方法的详细内容,更多请关注php中文网其它相关文章!
android – handler.postDelayed在IntentService的onHandleIntent方法中不起作用
final Handler handler = new Handler(); LOG.d("delay"); handler.postDelayed(new Runnable() { @Override public void run() { LOG.d("notify!"); //calling some methods here } },2000);
“延迟”确实显示在日志中,但根本不显示.并且在run()中调用的方法也根本不被调用.任何人都可以帮助解释为什么会发生这种情况,我做错了吗?
具有此代码的类扩展了IntentService,这会是一个问题吗?
============================
更新:
我将此代码放在扩展IntentService的类中.我发现它唯一有用的地方是构造函数.但我需要把它放在onHandleIntent方法中.所以我检查了onHandleIntent的文档,它说:
This method is invoked on the worker thread with a request to process.Only one Intent is processed at a time,but the processing happens on a worker thread that runs independently from other application logic. So,if this code takes a long time,it will hold up other requests to the same IntentService,but it will not hold up anything else. When all requests have been handled,the IntentService stops itself,so you should not call stopSelf.
所以基于我得到的结果,我觉得我不能在“工作线程”中使用postDelayed.但是,任何人都可以解释这一点,比如为什么这不适用于工作线程?提前致谢.
解决方法
HandlerThread handlerThread = new HandlerThread("background-thread"); handlerThread.start(); final Handler handler = new Handler(handlerThread.getLooper()); handler.postDelayed(new Runnable() { @Override public void run() { LOG.d("notify!"); // call some methods here // make sure to finish the thread to avoid leaking memory handlerThread.quitSafely(); } },2000);
或者您可以使用Thread.sleep(long millis).
try { Thread.sleep(2000); // call some methods here } catch (InterruptedException e) { e.printstacktrace(); }
如果要停止休眠线程,请使用yourThread.interrupt();
Android10+ FileNotFoundException: open failed: EACCES (Permission denied)
背景原因
Android 10(API 级别 29)引入了多项功能和行为变更,目的是更好地保护用户的隐私权。具体变更请跳转:https://developer.android.google.cn/about/versions/10/privacy/changes
android Q 规定了APP有两种外部存储空间视图模式:
Legacy View
、Filtered View
。采用了新的分区储存权限,老的存储权限READ_EXTERNAL_STORAGE/WRITE_EXTERNAL_STORAGE
废弃,替换成新的存储权限android.permission.READ_MEDIA_AUdio
、android.permission.READ_MEDIA_IMAGES
和android.permission.READ_MEDIA_VIDEO
,并且只提供了多媒体文件的读权限,未提供写权限,现在应用没有权限直接删除别的应用生成的任何文件,包括多媒体文件。
解决方案
- 自降版本
compileSdkVersion <= 27
(当然这个不建议,毕竟要跟随潮流) - 在清单文件
AndroidManifest.xml
中添加 :android:requestLegacyExternalStorage="true"
(指定分区按照以前的模式,也不是长久处理方式) - 使用
FileProvider
的Content Uri
替换File Uri
可以参考:
华为:Google Q版本应用兼容性整改指导
OPPO:Android Q版本应用兼容性适配指导
郭霖:Android 10适配要点,作用域存储
Android:FaceDetector不起作用. findface总是检测到零面;
我在使用android.media.FaceDetector的Android中遇到了人脸检测问题
我试图使用此代码检测面部:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.RGB_565;
Bitmap b = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+"/myimage.jpg", options);
FaceDetector fd = new FaceDetector(b.getWidth(), b.getHeight(), 1);
Face[] face = new Face[1];
int detected_face = fd.findFaces(b, face);
detected_face它总是0;
我试图使用不同的图像,但我收到了相同的结果.
有人可以解释一下我的代码有什么问题吗?
问候
解决方法:
下面的代码对我有用,而且我记得照片上的面孔必须是直立的,这意味着如果在图片中一个人站在他的头上,那么你必须将位图旋转180度才能将它送到FaceDetector,或者他的脸不会被发现)
private void detectFaces() {
int max = 5;
BitmapFactory.Options bfo = new BitmapFactory.Options();
bfo.inPreferredConfig = Bitmap.Config.RGB_565;
bfo.inScaled = false;
bfo.inDither = false;
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.myphoto, bfo);
int w = bitmap.getWidth();
int h = bitmap.getHeight();
FaceDetector fd = new FaceDetector(w, h, max);
Face[] faces = new Face[max];
int c = fd.findFaces(bitmap, faces);
for (int i=0;i<c;i++) {
Log.d("TAG", Float.toString(faces[i].eyesdistance()));
}
}
今天关于春季启动:accessDeniedHandler不起作用和accessdeniedhandler是干嘛的的介绍到此结束,谢谢您的阅读,有关AccessDenied错误解决方法、android – handler.postDelayed在IntentService的onHandleIntent方法中不起作用、Android10+ FileNotFoundException: open failed: EACCES (Permission denied)、Android:FaceDetector不起作用. findface总是检测到零面;等更多相关知识的信息可以在本站进行查询。
本文标签: