|
|
@ -6,7 +6,8 @@ import javax.servlet.ServletException;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* RequestUtil
|
|
|
|
* RequestUtil
|
|
|
@ -83,6 +84,50 @@ public class RequestUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getScheme(HttpServletRequest request) {
|
|
|
|
|
|
|
|
String url = request.getRequestURL().toString();
|
|
|
|
|
|
|
|
Pattern compile = Pattern.compile("(http|https)://(.*)/");
|
|
|
|
|
|
|
|
Matcher matcher = compile.matcher(url);
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
|
|
|
String group = matcher.group(1);
|
|
|
|
|
|
|
|
return group;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getDomain(HttpServletRequest request) {
|
|
|
|
|
|
|
|
String url = request.getRequestURL().toString();
|
|
|
|
|
|
|
|
Pattern compile = Pattern.compile("(http|https)://(.*)(:.*)?/");
|
|
|
|
|
|
|
|
Matcher matcher = compile.matcher(url);
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
|
|
|
String group = matcher.group(2);
|
|
|
|
|
|
|
|
return group;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static int getPort(HttpServletRequest request) {
|
|
|
|
|
|
|
|
String url = request.getRequestURL().toString();
|
|
|
|
|
|
|
|
Pattern compile = Pattern.compile("(http|https)://(.*)(:.*)?/");
|
|
|
|
|
|
|
|
Matcher matcher = compile.matcher(url);
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
|
|
|
String group = matcher.group(3);
|
|
|
|
|
|
|
|
if (group == null) {
|
|
|
|
|
|
|
|
return Integer.parseInt(group);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 80;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void setRedirect(String url) {
|
|
|
|
|
|
|
|
HttpServletResponse response = LocalData.getResponse();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
response.sendRedirect(url);
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void setRedirect(String url) {
|
|
|
|
public static void setRedirect(String url) {
|
|
|
|
HttpServletResponse response = LocalData.getResponse();
|
|
|
|
HttpServletResponse response = LocalData.getResponse();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|