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

项目配掉端口后有些路径访问不了的解决方法

2013-03-16 
项目配掉端口后有些路径访问不了的解决办法%?String path request.getContextPath()?String basePath

项目配掉端口后有些路径访问不了的解决办法

<%
?String path = request.getContextPath();
?String basePath = null;
?if (request.getServerPort() == 80) {
??basePath = request.getScheme() + "://"
????+ request.getServerName() + path + "/";
?} else {
??basePath = request.getScheme() + "://"
????+ request.getServerName() + ":"
????+ request.getServerPort() + path + "/";
?}
%>

上面这种问题,主要出现在开发,测试阶段,如果用ip+端口访问项目,加上apache之后,配掉端口,于是就默认的是80端口,项目有些路径访问不了(有ajax),所以可以采用上面这种方法来试试。

?

由于项目中很多地方都写了,所以都要改,以后记得把这种变量定义在一个公用的jsp页面,其他页面都引入这个页面。这种思想在开发中非常常见。

<%@ include file="/page/common/jsp/commons.jsp"%>

?

热点排行