你好 可以分享下 utils的源码么
有没有那个源码放到GitHub上啊??
记录系统用户的操作日志 采用方案: 使用spring 的 aop 技术切到自定义注解上,针对不同注解标志进行参数解析,记录日志缺点是要针对每个不同的注解标志进行分别取注解标志...
public class HttpContextUtils {
public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
}
import javax.servlet.http.HttpServletRequest;
public class IPUtils {
public static String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("x-real-ip");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("x-forwarded-for");
if (ip != null) {
ip = ip.split(",")[0].trim();
}
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
}
网上找的utils可以用