小编典典

JSP找不到样式表

jsp

层次结构:
WEB-INF / jsp
WEB-INF / styles

我在我的JSP文件中链接了样式表,该文件位于WEB-INF / jsp中:

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

但这不起作用!当我打开我的应用程序时,没有样式,也没有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 Framework3。我已经将文件夹中包含样式和图像的文件夹放在WEB-INF之外,但是仍然无法使用。我的jsp文件是这样写的:

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

而且不起作用…


阅读 336

收藏
2020-06-08

共1个答案

小编典典

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

<?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中仍然不起作用!

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

我的spring框架有3.0.5版本。

2020-06-08