• jsp页面路径问题


    jsp路径默认不是项目跟路径

    一、

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    %>
    
    <!doctype html>
    <html>
    <head>
     <base href="<%=basePath%>"> --------------------加入base,以后默认都是项目跟路径
    <meta charset="utf-8">
    <title>大客户网络维护管理系统</title>
    <jsp:include page="common/header.jsp"/>
    
        <script type="text/javascript" src="app/js/video/video.js"></script>
    </head>

    二、每个都设置绝对路径

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    
    <c:set var="ctx" value="${pageContext.request.contextPath}"        ---------------绝对路径
        scope="request" />
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1">
    <title>漂亮的easyui后台框架演示-css后台模板-www.16sucai.com</title>
    <link href="${ctx}/app/easyui/css/default.css" rel="stylesheet"          --------------绝对路径
        type="text/css" />
    <link rel="stylesheet" type="text/css"
        href="${ctx}/app/easyui/js/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css"
        href="${ctx}/app/easyui/js/themes/icon.css" />
    <script type="text/javascript"
        src="${ctx}/app/easyui/js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript"
        src="${ctx}/app/easyui/js/jquery.easyui.js"></script>
    
    <script type="text/javascript" src='${ctx}/app/easyui/js/outlook2.js'> </script>

    三、上述两者可以结合使用

    <base href="${pageContext.request.contextPath}">
  • 相关阅读:
    职场利器:说服力书籍排行榜
    经商必读的6本书推荐
    有关企业文化的书籍推荐
    创业书籍推荐
    企业文化建设的基本内容和主要步骤
    沟通书籍排行榜推荐
    企业文化建设案例与方案分享
    如何提高个人领导力?
    Project Recording: Date and Factory Date[转载]
    SAP Control framework–实例
  • 原文地址:https://www.cnblogs.com/zrui-xyu/p/5526166.html
Copyright © 2020-2023  润新知