html - 合并后将 Css 文件视为 html 文件

标签 html css jsp jakarta-ee

我在 github 上有两个分支。第二个是用于前端集成,在我将它与 master 合并之前一直运行良好。

我的 index.jsp 文件:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ex" uri="/WEB-INF/custom.tld" %>

<html>
<jsp:include page="pages/headFragment.jsp"/>

<body>
<body>
...
</body>
</html>

headFragment.jsp 是:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
<!-- Animate.css -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/animate.css">
    <!-- Icomoon Icon Fonts-->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/icomoon.css">
    <!-- Simple Line Icons -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/simple-line-icons.css">
</head>

在浏览器的控制台中我有几个错误: SyntaxError:预期的表达式,得到了“<” 但它们与不是 css 文件的 css 文件相关联。我的 animate.css 被浏览器解释为包含整个页面主体的 html 文件。链接被正常解释,但他们的正文不是。

我认为这是链接 css 样式表的问题,但我用谷歌搜索并尝试了很多选项,但没有任何效果。有趣的是,在前端集成部分它正常工作,但合并后它不包含 css 文件。 js文件也有问题,但我尝试先修复css ...

顺便说一句,我在 Intellij 2016.2.4 上工作

还有我的pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>webpage</groupId>
    <artifactId>web_page</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warSourceDirectory>web</warSourceDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <packaging>war</packaging>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.1-901.jdbc4</version>
        </dependency>

        <!-- http://repo1.maven.org/maven -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

</project>

最佳答案

它可能与谁有关。

问题的发生是因为加载的 servlet 的全局欢迎路径“/”。将此路径更改为 f.e. '/yolo' 解决所有冲突。

关于html - 合并后将 Css 文件视为 html 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39801314/

相关文章:

html - bower 安装 html5 样板是一件好事吗?

html - 如何使用 flex 将图像对齐到 div 的底部?

html - 在网站正文中围绕 Flash 内容在 CSS 中创建左右间隔符

java - 未找到页面 :1136 - No mapping found for HTTP request with URI [] in DispatcherServlet with name 'spring'

javascript - 使用 Javascript/Jquery 创建一行单元格 (DIV)

html - 带有内部空心边框的 Css 圆圈?

javascript - Jquery .load 导致按钮点击问题

java - 上传pdf文件

java - 如何在 page.redirect 从 servlet 到 jsp 上显示成功消息

css - 复选框切换 react