我已经尝试了很多天,我看到了很多帖子,我不能解决这个问题。当我想将css放入jsp并加载页面时,我有这样一个方法:
2019-11-15 11:00:38.895 warn 11504---[nio-8080-exec-7]o.s.web.servlet.pagenotfound:在名为“dispatcherservlet”的dispatcherservlet中找不到uri为[/resources/genius/css/carousel.css]的http请求的Map
我的树丛:
src-----
|main
--------
|java
--------
|resources
---------application-properties.txt
--------
|webapp
---------|resources
---------
| genius
---------|css
---------bootstrap.min.css
---------carousel.css
---------font-awesome.min.css
---------|font
---------|js
---------|images
---------style.css
---------|WEB-INF
我的jsp:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="en">
<head>
<link href="<c:url value="/resources/genius/css/carousel.css" />" rel="stylesheet">
<link href="<c:url value="/resources/genius/css/bootstrap.min.css" />" rel="stylesheet">
<link href="<c:url value="/resources/genius/css/font-awesome.min.css" />" rel="stylesheet">
<link href="<c:url value="/resources/style.css" />" rel="stylesheet">
<title>My title</title>
</head>
<body class ="left-menu">
<div class="menu-wrapper">
<header class="vertical-header">
<div class="vertical-header-wrapper">
<nav class="nav-menu">
<div class="logo">
</div>
</nav>
</div>
</header>
</div>
<div>
</div>
</body>
</html>
我试过和你谈谈
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<spring:url value="/resources/genius/css/bootstrap.min.css" var="bootstrapCss" />
<link href="${bootstrapCss}" rel="stylesheet" />
<spring:url value="/resources/genius/css/font-awesome.min.css" var="fontAwesomeCss" />
<link href="${fontAwesomeCss}" rel="stylesheet" />
<spring:url value="/resources/genius/css/carousel.css" var="carousel" />
<link href="${carousel}" rel="stylesheet" />
<spring:url value="/resources/genius/style.css" var="styleCss" />
<link href="${styleCss}" rel="stylesheet" />
但是没有找到标签Spring。。。
我的调度员:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources/genius/" />
<context:component-scan base-package="com.howtodoinjava.app.controller" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/jsp" /> <!-- /WEB-INF/jsp/ -->
<beans:property name="suffix" value="*.jsp" /><!-- .jsp -->
</beans:bean>
</beans:beans>
/web inf/jsp不工作。为了显示我的jsp,我必须遍历application.properties
spring.mvc.view.prefix=/WEB-INF/view/
spring.mvc.view.suffix=.jsp
logging.level.org.springframework=TRACE
logging.level.com=TRACE
所以我想知道是否有类似的东西做的css。
在另一个测试中,我尝试了:
<annotation-driven />
<mvc:resources mapping="/resources/**" location="/classpath:/resources/genius/" />
我对这次考试的看法是:
src-----
|main
--------
|java
--------
|resources
---------|resources
---------
| genius
---------|css
---------bootstrap.min.css
---------carousel.css
---------font-awesome.min.css
---------|font
---------|js
---------|images
---------style.css
---------application-properties.txt
--------
|webapp
---------|WEB-INF
我最后一次尝试的是添加我的调度程序。。。
谢谢你给我解释我忘了什么。
暂无答案!
目前还没有任何答案,快来回答吧!