之前用weblogic时,可以这么写:
<@include file="/jsp/myjsp.jsp">
红色的那个/就代表了网站的根路径了,但是现在用了tomcat,就不行了。
那么用tomcat时,怎么样才能方便的取到网站根路径下的css,js什么的?

解决方案 »

  1.   

    红杠前面加个“request.getContextPath()%”
      

  2.   

     /project/jsp/myjsp.jsp  project是项目名称
      

  3.   

    <link type="text/css" media="screen" rel="stylesheet" href="<%=request.getContextPath()%>/css/template.css">
    <script language="javascript" src="<%=request.getContextPath()%>/js/calendar.js"></script>
      

  4.   

    <jsp:include page="/jsp/myjsp.jsp"></jsp:include>
    直接加在body里面不就可以了
    就算你那样加,你都少了%<%@include file="/jsp/myjsp.jsp"%>