MockHttpServletRequestBuilder.java 文件源码

java
阅读 41 收藏 0 点赞 0 评论 0

项目:class-guard 作者:
/**
 * Update the contextPath, servletPath, and pathInfo of the request.
 */
private void updatePathRequestProperties(MockHttpServletRequest request, String requestUri) {
    Assert.isTrue(requestUri.startsWith(this.contextPath),
            "requestURI [" + requestUri + "] does not start with contextPath [" + this.contextPath + "]");
    request.setContextPath(this.contextPath);
    request.setServletPath(this.servletPath);
    if (ValueConstants.DEFAULT_NONE.equals(this.pathInfo)) {
        Assert.isTrue(requestUri.startsWith(this.contextPath + this.servletPath),
                "Invalid servletPath [" + this.servletPath + "] for requestURI [" + requestUri + "]");
        String extraPath = requestUri.substring(this.contextPath.length() + this.servletPath.length());
        this.pathInfo = (StringUtils.hasText(extraPath)) ? extraPath : null;
    }
    request.setPathInfo(this.pathInfo);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号