I'm trying to load my style sheet into a JSP page, with Spring and Maven, but the file does not recognize CSS, via import, I already tried several forms but it does not load, I need help:
Follow my code, to be an idea of how it is.
Package that configures Spring
package br.com.livrariaastec.loja.conf;
@Configuration
@EnableWebMvc
@ComponentScan(basePackageClasses= {HomeController.class})
public class AppWebConfiguration extends WebMvcConfigurerAdapter{
@Bean
public InternalResourceViewResolver InternalResourceViewResolver() {
org.springframework.web.servlet.view.InternalResourceViewResolver
resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
return resolver;
}
// ativar o spring para entender os styles
public void
configureDefaultServletHandling(DefaultServletHandlerConfigurer
configurer) {
configurer.enable();}
My home JSP
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<c:url value="/style.css"/>">
<title>Insert title here</title>
</head>
<body>
<h1>Foi</h1>
</body>
</html>
Package HomeController
@Controller
public class HomeController {
@RequestMapping("/")
public String index() {
System.out.println("nova home");
return "home";
}
}