【发布时间】:2021-03-11 01:53:03
【问题描述】:
我需要在 glassfish5 上运行的 jax-rs 应用程序的 jsp 文件中添加 css 和 js。 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>com.example</groupId>
<artifactId>elearning_ontology</artifactId>
<version>1.0-SNAPSHOT</version>
<name>elearning_ontology</name>
<packaging>war</packaging>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<junit.version>5.6.2</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.mvc</groupId>
<artifactId>javax.mvc-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.krazo</groupId>
<artifactId>krazo-jersey</artifactId>
<version>1.1.0-M1</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
<version>5.1.17</version>
</dependency>
<dependency>
<groupId>com.github.galigator.openllet</groupId>
<artifactId>openllet-owlapi</artifactId>
<version>2.6.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.0</version>
</plugin>
</plugins>
</build>
</project>
我尝试使用相对路径或c:url 添加css,但没有机会:
<link rel="stylesheet" href="<c:url value = "bootstrap-rtl.min.css"/>" media="screen">
<link rel="stylesheet" href="assets/css/bootstrap-rtl.min.css" media="screen">
当我查看页面源并单击 css url 时,我看到一个 404 页面。我想我应该通过 Application 或 web.xml 进行一些配置。但我不知道如何
P.S:它是一个 restfull mvc 应用程序。所以所有的路由都是通过控制器类来控制的。
所以(也许)只能访问在控制器中定义或在配置文件中定义的路径。相对或绝对路径不起作用。
【问题讨论】:
标签: intellij-idea jax-rs glassfish-5