[英]Access - To know from which country the user is accessing my application
In my web application , I need to give access only to the users who are accessing my application from India. 在我的Web应用程序中,我只需要访问从印度访问我的应用程序的用户。 I need to block the users from accessing my application when they try to access outside India.(ie, I willnot allow them to login and will show an error pop-up) Can anyone please tell if this is possible?
当我们试图访问印度以外的地方时,我需要阻止用户访问我的应用程序。(即,我不允许他们登录并显示错误弹出窗口)任何人都可以告诉我这是否可行?
Add a Filter
which checks for requests and 添加一个
Filter
,用于检查请求和
String ip = request.getRemoteAddress();
Use hostip service api to check for location 使用hostip service api检查位置
For example 例如
http://api.hostip.info/country.php?ip=74.125.236.206
This will give you country code IN
这将为您提供国家代码
IN
If you don't get IN
then from Filter 如果你没有从过滤器获得
IN
response.sendRedirect("someUrl");
return;
otherwise allow request 否则允许请求
chain.doFilter(request, wrapper);
See 看到
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.