2017-04-03 60 views

回答

0

如果我正確理解你的問題,你想獲得在servlet類Path.java部署的.war文件中的contextPath [我假設你正在使用servlet這裏],

public static String getURLWithContextPath(HttpServletRequest request) { 
    return request.getContextPath(); // this method will provide you desired path. 
} 

有關詳細contextPath,

https://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpServletRequest.html#getContextPath()

+0

Path.java不是servlet。這是簡單的java類。我們如何從簡單的java類獲取contextpath? –

相關問題