jsp页面取得根路径

${pageContext.request.contextPath}


如果从controller则如下方式取:

    public String myfunction( HttpServletRequest request, HttpServletResponse response, Model model)
    {
        String baseUrl = String.format("%s://%s:%d%s/", request.getScheme(),
                request.getServerName(), request.getServerPort(),
                request.getContextPath());

你可能感兴趣的:(jsp页面取得根路径)