Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
can';t在Struts2中应用外部CSS_Css_Jsp_Struts2 - Fatal编程技术网

can';t在Struts2中应用外部CSS

can';t在Struts2中应用外部CSS,css,jsp,struts2,Css,Jsp,Struts2,我有一个带有struts2框架的Java web应用程序。在我的index.jsp文件中,我链接了CSS文件,但它没有显示在我的页面中,并且错误404:notfound显示在Firebug中。我测试了一个没有Struts的应用程序,一切都很好。但是当我添加struts2库和configstruts.xml和web.xml文件时,CSS不会显示:( 这是我的index.jsp: <head> <meta http-equiv="Content-Type" content=

我有一个带有struts2框架的Java web应用程序。在我的
index.jsp
文件中,我链接了CSS文件,但它没有显示在我的页面中,并且
错误404:notfound
显示在
Firebug
中。我测试了一个没有Struts的应用程序,一切都很好。但是当我添加struts2库和config
struts.xml
web.xml
文件时,CSS不会显示:( 这是我的index.jsp:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="styles/main.css" rel="stylesheet" type="text/css"/>
</head>

当然,我添加了
并在href中尝试了
,但没有看到任何效果。 以下是web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>

    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
             version="3.0">
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>

        <display-name>HotelSystem</display-name>
            <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
            </welcome-file-list>
        <filter>
            <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        </filter>

        <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    </web-app>

30
酒店系统
index.jsp
支柱2
org.apache.struts2.dispatcher.ng.filter.strutspreadexecutefilter
支柱2
/*
下面是我的struts.xml的一部分:

<package name="default" namespace="/" extends="struts-default">
        <action name="index.jsp" class="Actions.Test">
            <result name="success">/index.jsp</result>
        </action>
    </package>

/index.jsp

注意:
操作.Test
是一个测试操作,总是返回成功。

您应该在web.xml文件中映射.css类型,如下所示

<filter-mapping>
    <filter-name>expires-filter</filter-name>
    <url-pattern>*.css</url-pattern>
</filter-mapping>

过期过滤器
*.css

永远不要写我真的需要尽快解决这个问题。如果你真的想快速解决问题,或者根本不想解决问题,请任何人再次帮助我……使用Firebug,你可以尝试从生成的HTML打开CSS。试试,看看结果路径。这将是错误的,你会发现如何解决;你可能需要一个在
样式/
之前添加斜杠。