---
title: "struts2.0 action转跳到jsp页面css失效解决方案"
author: "andy136566"
date: "2011-02-14T19:40:18Z"
tags: []
categories: ["Web前端"]
slug: "struts2-0-action-jsp-css"
draft: false
lastmod: "2011-02-14T19:40:18Z"
id: 906201
url: "https://andy136566.iteye.com/blog/906201"
---

像页面转跳失效问题肯定是路径的问题。建议改相对路径为绝对路径。

Java代码 [![复制代码](/images/icon_copy.gif)](# "复制代码")

1. String path = request.getContextPath();
2. String basePase = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

```
String path = request.getContextPath();
String basePase = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
```

引用css:

Html代码 [![复制代码](/images/icon_copy.gif)](# "复制代码")

1. **&lt;link** rel="stylesheet" type="text/css" href="&lt;%=basePath%&gt;main.css"**&gt;**

```
<link rel="stylesheet" type="text/css" href="<%=basePath%>main.css">
```

转：[http://jnotnull.iteye.com/blog/198735](http://jnotnull.iteye.com/blog/198735)