У меня проблема с применением файла css. Мое приложение учитывает мой файл css, когда у меня есть 1 сервлет. За исключением того, что когда я добавляю второй сервлет, jsp больше не учитывает мой файл css. И когда я go вернусь к одному сервлету, появится еще один способ применить мой css файл
Организация:

Страница . java:
package com.oc;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name = "/")
public class Page extends HttpServlet{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.getServletContext().getRequestDispatcher("/WEB-INF/view/page.jsp").forward(request,response);
}
}
Page2. java:
package com.oc;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name = "/page2")
public class Page2 extends HttpServlet{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.getServletContext().getRequestDispatcher("/WEB-INF/view/page2.jsp").forward(request,response);
}
}
spring-web-config. xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<mvc:resources mapping="/resources/**" location="/resources/" />
</beans>
style. css:
body{
background: #0c5460;
}
head{
background: #721c24;
}
page. jsp:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Page 1</title>
<link href="<c:url value="/resources/style.css" />" rel="stylesheet">
</head>
<body>
<h1>1. Test CSS : page 1</h1>
<p> Page test for insertion CSS</p>
</body>
</html>
page2. jsp:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Page 2</title>
<link href="<c:url value="/resources/style.css" />" rel="stylesheet">
</head>
web. xml перед добавлением сервлеты отображения page2:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>page</servlet-name>
<servlet-class>com.oc.Page</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>page</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
<body>
<h1>1. Test CSS : page 2</h1>
<p> Page test for insertion CSS</p>
</body>
</html>
Web. xml со второй страницей:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>page</servlet-name>
<servlet-class>com.oc.Page</servlet-class>
</servlet>
<servlet>
<servlet-name>page2</servlet-name>
<servlet-class>com.oc.Page2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>page</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>page2</servlet-name>
<url-pattern>/2</url-pattern>
</servlet-mapping>
</web-app>
Когда я смотрю на источник в проверке, стиль. css становится jsp:
