how should I get root folder path in jsp page

前端 未结 5 1360
南笙
南笙 2020-12-18 00:00

I want to retrieve root path of webapplication, then I want to append link to root path. I tried request.context but it returns \"http://localhost:8080/webapp/web-inf\".

5条回答
  •  天涯浪人
    2020-12-18 00:30

    You can use pageContext.request.contextPath

    ${pageContext.request.contextPath}
    

    So you can use,

    name
    

    But the better way is to set the base href to this path and then use the path as it is.

    
    
            
    
        
    
    name
    
    
    

提交回复
热议问题