jsp页面设置绝对路径

例子: 设置完之后就随便jsp页面放在哪个文件夹都可以加载到资源了

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
    String path=request.getContextPath();
    String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
    <meta charset="utf-8">
    <meta name="viewport" content="user-scalable=no,width=device-width,initial-scale=1,maximum-scale=1">
    <title>yun70商户注册</title>
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/common.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/login.css">
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
</head>

 

   

posted @ 2017-10-10 15:41  随意随性  阅读(477)  评论(0编辑  收藏  举报