Spring MVC does not recognize static page - CSS

Asked

Viewed 40 times

-1

I am doing a project in java using Spring MVC and when implementing the technology my page stopped being stylized, I already looked for the solution in other questions, in the documentation of spring, and even I stopped other projects using Spring on Github, and the settings are the same as in my project. I don’t know why it doesn’t work, if someone wants to see my entire project is on Github https://github.com/Jo4o-Pedro/Sistema-Lanchonete-.git But I believe from the information here you can help me. Here is the structure of the project:

inserir a descrição da imagem aqui

The methods I’m using in the configuration class:

   @Configuration
   @EnableWebMvc
   @ComponentScan(basePackages = {"lanchonete.com.br.sistemaaps"})

   public class AppWebConfig extends WebMvcConfigurationSupport {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
    }

      // equivalent for <mvc:default-servlet-handler/> tag
     @Override
     public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
     }
   }

And the header of my jsp:

<%@page import="models.Usuario" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html lang="pt-br">
<head>
   <meta charset='utf-8'>
   <title>Pagina Principal</title>
   <meta name='viewport' content='width=device-width, initial-scale=1'>
   <link rel="stylesheet" type="text/css" href="<c:url value="/resources/estiloaps.css" />" />

</head>

1 answer

0


I ended up finding the solution that was the lack of two dependencies:

<dependency>
     <groupId>javax.servlet</groupId>
     <artifactId>javax.servlet-api</artifactId>
     <version>4.0.0</version>
     <scope>provided</scope>
  </dependency>
  <dependency>
     <groupId>javax.servlet.jsp</groupId>
     <artifactId>javax.servlet.jsp-api</artifactId>
     <version>2.3.2-b02</version>
     <scope>provided</scope>
  </dependency>

After that and with the settings mentioned in the question, it worked correctly

Browser other questions tagged

You are not signed in. Login or sign up in order to post.