我需要基于客户端IP地址来限制视图,我有静态IP地址列表,并且只想向那些在我的Java Web应用程序中注册了IP地址的用户显示视图
Depends upon how you want to achieve the filtering.
If I were you, I would use a filter, that way you are not even touching the Servlet layer with that IP.
See this link to know about Servlet Filters - http://docs.oracle.com/javaee/6/tutorial/doc/bnagb.html
It depends on what you would like to do.
Among other things you can filter out (restrict) the view of your applications to certain IPs only by configuring the server.
How to do it depends on the server.
For example for Tomcat you would need to edit the org.apache.catalina.valves.RemoteAddrValve
in the context
(filename: context.xml
). See also: http://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Remote_Address_Filter
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.