JSP找不到样式表 [英] JSP can't find stylesheet

查看:190
本文介绍了JSP找不到样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

层次结构:

WEB-INF / jsp

WEB-INF / styles

Hierarchy:
WEB-INF/jsp
WEB-INF/styles

文件,位于WEB-INF / jsp:

I link stylesheet in my JSP file, which is located in WEB-INF/jsp:

 <link rel="stylesheet" type="text/css" href="../styles/reset.css" />

但它不工作!
当我打开我的应用程序没有样式,并由Tomcat写入:

But it doesn't work! When i open my application there is no styles, and writter by Tomcat:

<html><head><title>Apache Tomcat/7.0.14 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The requested resource () is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.14</h3></body></html>

如何克服?

我的专案:
http://img835.imageshack.us/img835/6159/ 73536381.jpg

我使用的是spring框架3.
我把我的文件夹的样式和图像在WEB-INF之外,但它仍然不工作。
我的jsp文件是:

I am using spring framework 3. I've put my folders with styles and images outside of WEB-INF but it still doesn't work. I my jsp file is written:

<link rel="stylesheet" type="text/css" href="resources/styles/styles.css" />

它不工作...

推荐答案

我发现了 http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-static-resources
现在我的rus-servlet.xml看起来像这样:

I've found http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-static-resources So now my rus-servlet.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd 
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
        <context:component-scan base-package="rus.web"/>
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/WEB-INF/jsp/"/>
            <property name="suffix" value=".jsp"/>
        </bean>
        <mvc:annotation-driven/>
        <mvc:resources mapping="/resources/**" location="/resources/"/>
</beans>

但是这在JSP中仍然不起作用!

But this in JSP still doesn't work!

<link rel="stylesheet" type="text/css" href="resources/styles/styles.css" />

我有3.0.5版本的我的spring框架。

And i have 3.0.5 version of my spring framework.

这篇关于JSP找不到样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆