一,获取当前的系统路径,得到项目的名字 String path = request.getContextPath();
假如注释掉String path = request.getContextPath();运行页面就会报500错误。
先声明后使用
<%
String path = request.getContextPath();
%>
<link rel="stylesheet" type="text/css" href="<%=path%>/producemanager/style/common.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/producemanager/style/cuimod.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/producemanager/js/jquery-easyui-1.4.4/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/producemanager/js/jquery-easyui-1.4.4/themes/icon.css"/>
<script type="text/javascript" src="<%=path%>/producemanager/js/jquery-easyui-1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/producemanager/js/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=path%>/producemanager/js/layer/layer.js"></script>
<script type="text/javascript">
var path = "<%=path%>";
function refresh(){
/* window.location.reload();页面实现跳转和刷新 */
window.location.reload();
}
</script>
<div class="slect-bnt"><a class="cui-back" href="<%=path%>/qjqk_cplx.jsp" onclick="search();"></a></div>
<a class="cui-back" href="<%=path%>/sczxPage.jsp" title="返回上一级">
<img src="<%=path%>/producemanager/style/img/backicon.png" /></a>
<a class="cui-back" href="#" onclick="refresh()" style="right:150px;"title="刷新"><img src="<%=path%>/producemanager/style/img/refresh.png" /></a>
<iframe allowtransparency="true" scrolling="no" frameborder="0" style="height:400px; width:100%;" src="<%=path%>/producemanager/qjjh/qjzl.jsp"></iframe>
$.ajax({
url: path+"/qjjh/QJ_ajaxGetPiChan",
type: 'POST',
success: function(result){
addSearchBox(result);
/* layer.close(loadingLayer_pc); */
}
});
//添加的方法 传参:产品型号
function opencpDetalT(value){
var url = path+'/producemanager/qjjh/threeTable.jsp?params='+encodeURI(encodeURI(value, 'UTF-8'), 'UTF-8');
//window.showModalDialog(url,window,"dialogWidth=900px;dialogHeight=410px;center:yes;status:no;scrollbars:auto");
showTable("各车间缺件种类明细",url);
}
function syncData(){
$.ajax({
url: "<%=path%>/qnjh/QNJH_syncData",
type: 'POST',
data: {'tableFunctionName':'T_SCXT_ERP_QJ','datasource':'scxt'},
success: function(result){
if (result == '0') {
alert('数据同步成功!');
location.href = location.href;
}
}
});
}
<a href="<%=request.getContextPath()%>/xxxx.jsp">中的request.getContextPath()应该是获取当前的系统路径,得到项目的名字,如果项目为根目录,则得到一个"",即空的字条串;
如果项目为ProduceManager, <%=request.getContextPath()% >/ xxxx.jsp将得到ProduceManager/xxxx.jsp,服务器端的路径则会自动加上,
<a href="XXXX.jsp"> 应该就是指当前路径下的这个xxx.jsp页面
二,将项目部署到Tomcat服务器上
当使用Tomcat作为Web服务器,项目一般部署在Tomcat下的webapps的目录下。具体来说主要用两种部署的路径: