🎨Style: 字符串判空写法
This commit is contained in:
@@ -19,13 +19,13 @@ public class NetUtils {
|
|||||||
*/
|
*/
|
||||||
public static String getIpAddress(HttpServletRequest request) {
|
public static String getIpAddress(HttpServletRequest request) {
|
||||||
String ip = request.getHeader("x-forwarded-for");
|
String ip = request.getHeader("x-forwarded-for");
|
||||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) {
|
||||||
ip = request.getHeader("Proxy-Client-IP");
|
ip = request.getHeader("Proxy-Client-IP");
|
||||||
}
|
}
|
||||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) {
|
||||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||||
}
|
}
|
||||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) {
|
||||||
ip = request.getRemoteAddr();
|
ip = request.getRemoteAddr();
|
||||||
if (ip.equals("127.0.0.1")) {
|
if (ip.equals("127.0.0.1")) {
|
||||||
// 根据网卡取本机配置的 IP
|
// 根据网卡取本机配置的 IP
|
||||||
|
|||||||
Reference in New Issue
Block a user