首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

tomcat不必项目名即可访问该项目配置

2012-09-07 
tomcat无需项目名即可访问该项目配置Host namelocalhostappBasewebappsunpackWARstrue autoDepl

tomcat无需项目名即可访问该项目配置

      <Host name="localhost"  appBase="webapps"            unpackWARs="true" autoDeploy="true"            xmlValidation="false" xmlNamespaceAware="false"><Context path="" docBase="/twithandSite"/>      </Host>


由于path="",所以项目中
String path = request.getContextPath();String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort();request.setAttribute("base", basePath);

得到的 request.getContextPath()=null;

访问地址:从http://192.168.0.27:8080/twithandSite变为:ttp://192.168.0.27:8080



.

热点排行