org.springframework.web.bind.annotation.RequestMethod#TRACE源码实例Demo

下面列出了org.springframework.web.bind.annotation.RequestMethod#TRACE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: guardedbox   文件: ErrorHandlingConfig.java
/**
 * Error handler.
 *
 * @return Unauthorized (401), Forbidden (403) or Not Found (404) with no body.
 */
@RequestMapping(value = "/error", method = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT,
        RequestMethod.DELETE, RequestMethod.HEAD, RequestMethod.OPTIONS, RequestMethod.PATCH, RequestMethod.TRACE})
public ResponseEntity<?> error() {

    Map<String, Object> requestErrorAttributes = errorAttributes.getErrorAttributes(
            new ServletWebRequest(request), ErrorAttributeOptions.defaults());
    HttpStatus errorStatus = HttpStatus.valueOf((Integer) requestErrorAttributes.get("status"));

    if (HttpStatus.UNAUTHORIZED.equals(errorStatus) || HttpStatus.FORBIDDEN.equals(errorStatus)) {
        session.invalidate();
        return new ResponseEntity<>(errorStatus);
    } else {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

}
 
源代码2 项目: zstack   文件: TestLibController.java
@RequestMapping(
        value = "/**",
        method = {
                RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE, RequestMethod.GET,
                RequestMethod.HEAD, RequestMethod.OPTIONS, RequestMethod.PATCH, RequestMethod.TRACE
        }
)
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    Test.handleHttp(request, response);
}
 
@RequestMapping(value = "/myPath.do", method = RequestMethod.TRACE)
public void trace() {
}
 
@RequestMapping(value = "/myPath.do", method = RequestMethod.TRACE)
public void trace() {
}
 
/**
 * Mapping to several HTTP request methods is not OK if it's a mix of unprotected and protected HTTP request methods.
 */
@RequestMapping(value = "/request-mapping-all-unprotected-methods-and-one-protected-method",
        method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.TRACE, RequestMethod.OPTIONS, RequestMethod.PATCH})
public void requestMappingAllUnprotectedMethodsAndOneProtectedMethod() {
}
 
/**
 * Mapping to the HTTP request method `TRACE` is safe as long as no state-changing operations are performed within this method.
 */
@RequestMapping(value = "/request-mapping-trace", method = RequestMethod.TRACE)
public void requestMappingTrace() {
}
 
/**
 * Mapping to several HTTP request methods is fine as long as all the HTTP request methods used are unprotected.
 */
@RequestMapping(value = "/request-mapping-several-unprotected-methods",
        method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.TRACE, RequestMethod.OPTIONS})
public void requestMappingSeveralUnprotectedMethods() {
}
 
@RequestMapping(value = "/myPath.do", method = RequestMethod.TRACE)
public void trace() {
}
 
@RequestMapping(value = "/myPath.do", method = RequestMethod.TRACE)
public void trace() {
}