Search in sources :

Example 46 with ServletRequestAttributes

use of org.springframework.web.context.request.ServletRequestAttributes in project spring-boot-quick by vector4wang.

the class WebLogAspect method doBefore.

@Before("logPointCut()")
public void doBefore(JoinPoint joinPoint) throws Throwable {
    // 接收到请求,记录请求内容
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    // 记录下请求内容
    loggger.info("请求地址 : " + request.getRequestURL().toString());
    loggger.info("HTTP METHOD : " + request.getMethod());
    loggger.info("IP : " + request.getRemoteAddr());
    loggger.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
    loggger.info("参数 : " + Arrays.toString(joinPoint.getArgs()));
// loggger.info("参数 : " + joinPoint.getArgs());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes)

Example 47 with ServletRequestAttributes

use of org.springframework.web.context.request.ServletRequestAttributes in project spring-boot-quick by vector4wang.

the class WebLogAspect method doBefore.

@Before("logPointCut()")
public void doBefore(JoinPoint joinPoint) throws Throwable {
    // 接收到请求,记录请求内容
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    // 记录下请求内容
    loggger.info("请求地址 : " + request.getRequestURL().toString());
    loggger.info("HTTP METHOD : " + request.getMethod());
    loggger.info("IP : " + request.getRemoteAddr());
    loggger.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
    loggger.info("参数 : " + Arrays.toString(joinPoint.getArgs()));
// loggger.info("参数 : " + joinPoint.getArgs());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes)

Example 48 with ServletRequestAttributes

use of org.springframework.web.context.request.ServletRequestAttributes in project spring-boot-quick by vector4wang.

the class WebLogAspect method doBefore.

@Before("logPointCut()")
public void doBefore(JoinPoint joinPoint) throws Throwable {
    // 接收到请求,记录请求内容
    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = attributes.getRequest();
    // 记录下请求内容
    loggger.info("请求地址 : " + request.getRequestURL().toString());
    loggger.info("HTTP METHOD : " + request.getMethod());
    loggger.info("IP : " + request.getRemoteAddr());
    loggger.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
    loggger.info("参数 : " + Arrays.toString(joinPoint.getArgs()));
// loggger.info("参数 : " + joinPoint.getArgs());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes)

Example 49 with ServletRequestAttributes

use of org.springframework.web.context.request.ServletRequestAttributes in project kork by spinnaker.

the class GenericErrorController method error.

@RequestMapping(value = "/error")
public Map error(@RequestParam(value = "trace", defaultValue = "false") Boolean includeStackTrace, HttpServletRequest httpServletRequest) {
    ServletRequestAttributes servletRequestAttributes = new ServletRequestAttributes(httpServletRequest);
    Map<String, Object> attributes = errorAttributes.getErrorAttributes(servletRequestAttributes, includeStackTrace);
    Throwable exception = errorAttributes.getError(servletRequestAttributes);
    if (exception != null && exception instanceof HasAdditionalAttributes) {
        attributes.putAll(((HasAdditionalAttributes) exception).getAdditionalAttributes());
    }
    return attributes;
}
Also used : HasAdditionalAttributes(com.netflix.spinnaker.kork.web.exceptions.HasAdditionalAttributes) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 50 with ServletRequestAttributes

use of org.springframework.web.context.request.ServletRequestAttributes in project com.revolsys.open by revolsys.

the class HttpServletRequestJexlContext method getRequest.

private HttpServletRequest getRequest() {
    final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    final HttpServletRequest request = requestAttributes.getRequest();
    return request;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes)

Aggregations

ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)204 HttpServletRequest (javax.servlet.http.HttpServletRequest)92 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)62 RequestAttributes (org.springframework.web.context.request.RequestAttributes)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)32 Test (org.junit.jupiter.api.Test)28 lombok.val (lombok.val)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)22 Test (org.junit.Test)18 AuthChecker (com.code.server.login.anotation.AuthChecker)17 HttpSession (javax.servlet.http.HttpSession)12 Before (org.junit.Before)12 HashMap (java.util.HashMap)11 Method (java.lang.reflect.Method)8 Date (java.util.Date)7 AbstractTracingSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan)7 TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)7 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)6 Map (java.util.Map)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6