---
title: "跳转页面后CSS或JS失效问题"
author: "submaze"
date: "2012-11-18T11:01:01Z"
tags: []
categories: ["Web前端"]
slug: "css-js"
draft: false
lastmod: "2012-11-18T11:01:01Z"
id: 1728647
url: "https://submaze.iteye.com/blog/1728647"
---

主要是路径解析的问题

如果在页面中使用的不是绝对地址，例如   href="css/reset.css"

跳转后的页面要解析出正确的css地址,可以在jsp的<head>中添加下面的代码


```html


<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<base href="<%=basePath%>">


```