我感到非常沮丧。 我试图在我的网络应用程序上拥有静态资源(css、js 等)。我更喜欢以一种漂亮且可接受的方式将它放在它自己的 servlet 中,但此时我并不关心它的外观,只要它能工作即可。我尝试了许多不同的方法,但我又回到尝试在 todo-servlet.xml 中使用资源映射,并一直尝试以这种方式访问资源。我将包含一些代码。任何帮助都会很棒。
错误
...
Details: org.springframework.security.web.authentication.WebAuthenticationDetails@fffe9938: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: FF8AF3382877259D176ED83243961B8A; Granted Authorities: ROLE_ANONYMOUS'
DEBUG 2017-08-05 04:48:30,029 [http-bio-8080-exec-5] org.springframework.security.web.FilterChainProxy - /Angular_Full_Version/css/style.css at position 11 of 13 in additional filter chain; firing Filter: 'SessionManagementFilter'
DEBUG 2017-08-05 04:48:30,029 [http-bio-8080-exec-2] org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcher' processing GET request for [/Angular_Full_Version/css/animate.css]
DEBUG 2017-08-05 04:48:30,029 [http-bio-8080-exec-5] org.springframework.security.web.FilterChainProxy - /Angular_Full_Version/css/style.css at position 12 of 13 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
DEBUG 2017-08-05 04:48:30,029 [http-bio-8080-exec-5] org.springframework.security.web.FilterChainProxy - /Angular_Full_Version/css/style.css at position 13 of 13 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
DEBUG 2017-08-05 04:48:30,029 [http-bio-8080-exec-2] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /Angular_Full_Version/css/animate.css
DEBUG 2017-08-05 04:48:30,029 [http-bio-8080-exec-5] org.springframework.security.web.util.matcher.AntPathRequestMatcher - Checking match of request : '/angular_full_version/css/style.css'; against '/login'
DEBUG 2017-08-05 04:48:30,029 [http-bio-8080-exec-5] org.springframework.security.web.util.matcher.AntPathRequestMatcher - Checking match of request : '/angular_full_version/css/style.css'; against '/*todo*/**'
DEBUG 2017-08-05 04:48:30,029 [http-bio-8080-exec-5] org.springframework.security.web.util.matcher.AntPathRequestMatcher - Checking match of request : '/angular_full_version/css/style.css'; against '/*admin*/**'
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-5] org.springframework.security.web.util.matcher.AntPathRequestMatcher - Checking match of request : '/angular_full_version/css/style.css'; against '/*user*/**'
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-5] org.springframework.security.web.access.intercept.FilterSecurityInterceptor - Public object - authentication not attempted
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-5] org.springframework.security.web.FilterChainProxy - /Angular_Full_Version/css/style.css reached end of additional filter chain; proceeding with original chain
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-5] org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcher' processing GET request for [/Angular_Full_Version/css/style.css]
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-5] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /Angular_Full_Version/css/style.css
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-6] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/Angular_Full_Version/font-awesome/css/font-awesome.css]
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-6] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /Angular_Full_Version/font-awesome/css/font-awesome.css
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-9] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/Angular_Full_Version/css/bootstrap.min.css]
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-9] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /Angular_Full_Version/css/bootstrap.min.css
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-2] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/Angular_Full_Version/css/animate.css]
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-2] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /Angular_Full_Version/css/animate.css
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-5] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/Angular_Full_Version/css/style.css]
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-5] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /Angular_Full_Version/css/style.css
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-9] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/Angular_Full_Version/css/bootstrap.min.css]
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-6] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/Angular_Full_Version/font-awesome/css/font-awesome.css]
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-6] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Matching patterns for request [/Angular_Full_Version/font-awesome/css/font-awesome.css] are [/Angular_Full_Version/**]
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-6] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - URI Template variables for request [/Angular_Full_Version/font-awesome/css/font-awesome.css] are {}
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-9] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Matching patterns for request [/Angular_Full_Version/css/bootstrap.min.css] are [/Angular_Full_Version/**]
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-6] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapping [/Angular_Full_Version/font-awesome/css/font-awesome.css] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/style]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@76de0cc1]]] and 1 interceptor
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-9] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - URI Template variables for request [/Angular_Full_Version/css/bootstrap.min.css] are {}
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-6] org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/Angular_Full_Version/font-awesome/css/font-awesome.css] is: -1
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-9] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapping [/Angular_Full_Version/css/bootstrap.min.css] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/style]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@76de0cc1]]] and 1 interceptor
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-2] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/Angular_Full_Version/css/animate.css]
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-9] org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/Angular_Full_Version/css/bootstrap.min.css] is: -1
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-5] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/Angular_Full_Version/css/style.css]
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-5] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Matching patterns for request [/Angular_Full_Version/css/style.css] are [/Angular_Full_Version/**]
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-5] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - URI Template variables for request [/Angular_Full_Version/css/style.css] are {}
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-5] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapping [/Angular_Full_Version/css/style.css] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/style]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@76de0cc1]]] and 1 interceptor
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-5] org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/Angular_Full_Version/css/style.css] is: -1
DEBUG 2017-08-05 04:48:30,030 [http-bio-8080-exec-2] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Matching patterns for request [/Angular_Full_Version/css/animate.css] are [/Angular_Full_Version/**]
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-2] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - URI Template variables for request [/Angular_Full_Version/css/animate.css] are {}
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-2] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapping [/Angular_Full_Version/css/animate.css] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/style]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@76de0cc1]]] and 1 interceptor
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-2] org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/Angular_Full_Version/css/animate.css] is: -1
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-5] org.springframework.security.web.context.HttpSessionSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-9] org.springframework.security.web.context.HttpSessionSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-6] org.springframework.security.web.context.HttpSessionSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-6] org.springframework.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-5] org.springframework.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-9] org.springframework.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-6] org.springframework.web.servlet.DispatcherServlet - Successfully completed request
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-9] org.springframework.web.servlet.DispatcherServlet - Successfully completed request
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-5] org.springframework.web.servlet.DispatcherServlet - Successfully completed request
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-2] org.springframework.security.web.context.HttpSessionSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-9] org.springframework.security.web.access.ExceptionTranslationFilter - Chain processed normally
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-6] org.springframework.security.web.access.ExceptionTranslationFilter - Chain processed normally
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-5] org.springframework.security.web.access.ExceptionTranslationFilter - Chain processed normally
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-9] org.springframework.security.web.context.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-5] org.springframework.security.web.context.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-2] org.springframework.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-6] org.springframework.security.web.context.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-2] org.springframework.web.servlet.DispatcherServlet - Successfully completed request
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-2] org.springframework.security.web.access.ExceptionTranslationFilter - Chain processed normally
DEBUG 2017-08-05 04:48:30,031 [http-bio-8080-exec-2] org.springframework.security.web.context.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed
<code>
标题.jspf
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
<title>QCC Greenhouse</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Page title set in pageTitle directive -->
<title page-title></title>
<!-- Bootstrap -->
<link href="<c:url value="/Angular_Full_Version/css/bootstrap.min.css"/>" rel="stylesheet">
<!-- Font awesome -->
<link href="<c:url value="/Angular_Full_Version/font-awesome/css/font-awesome.css"/>" rel="stylesheet">
<!-- Main Inspinia CSS files -->
<link href="<c:url value="/Angular_Full_Version/css/animate.css"/>" rel="stylesheet">
<link id="loadBefore" href="<c:url value="/Angular_Full_Version/css/style.css"/>" rel="stylesheet">
</head>
<body>
导航.jspf
<nav role="navigation" class="navbar navbar-default">
<div class="">
<a href="http://www.in28minutes.com" class="navbar-brand">in28Minutes</a>
</div>
<div class="navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/">Home</a></li>
<li><a href="/list-todos">Todos</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/logout">Logout</a></li>
</ul>
</div>
</nav>
index.jsp
<%@ include file="../common/header.jspf"%>
<%@ include file="../common/navigation.jspf"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!-- ControllerAs syntax -->
<!-- Main controller with serveral data used in Inspinia theme on diferent view -->
<body ng-controller="MainCtrl as main" class="{{$state.current.data.specialClass}}" landing-scrollspy id="page-top">
<!-- Main view -->
<div ui-view></div>
<!-- jQuery and Bootstrap -->
<script href="<c:url value="/Angular_Full_Version/js/jquery/jquery-3.1.1.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/plugins/jquery-ui/jquery-ui.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/bootstrap/bootstrap.min.js"/>"></script>
<!-- MetsiMenu -->
<script href="<c:url value="/Angular_Full_Version/js/plugins/metisMenu/jquery.metisMenu.js"/>"></script>
<!-- SlimScroll -->
<script href="<c:url value="/Angular_Full_Version/js/plugins/slimscroll/jquery.slimscroll.min.js"/>"></script>
<!-- Peace JS -->
<script href="<c:url value="/Angular_Full_Version/js/plugins/pace/pace.min.js"/>"></script>
<!-- Custom and plugin javascript -->
<script href="<c:url value="/Angular_Full_Version/js/inspinia.js"/>"></script>
<!-- Main Angular scripts-->
<script href="<c:url value="/Angular_Full_Version/js/angular/angular.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/angular/angular-sanitize.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/plugins/oclazyload/dist/ocLazyLoad.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/angular-translate/angular-translate.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/ui-router/angular-ui-router.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/bootstrap/ui-bootstrap-tpls-1.1.2.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/plugins/angular-idle/angular-idle.js"/>"></script>
<!--
You need to include this script on any page that has a Google Map.
When using Google Maps on your own site you MUST signup for your own API key at:
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
After your sign up replace the key in the URL below..
-->
<script type="text/javascript" href="https://maps.googleapis.com/maps/api/js?key=AIzaSyDQTpXj82d8UpCi97wzo_nKXL7nYrd4G70"/>"></script>
<!-- Anglar App Script -->
<script href="<c:url value="/Angular_Full_Version/js/app.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/config.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/translations.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/directives.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/controllers.js"/>"></script>
<%@ include file="../common/footer.jspf"%>
页脚.jspf
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- jQuery and Bootstrap -->
<script href="<c:url value="/Angular_Full_Version/js/jquery/jquery-3.1.1.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/plugins/jquery-ui/jquery-ui.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/bootstrap/bootstrap.min.js"/>"></script>
<!-- MetsiMenu -->
<script href="<c:url value="/Angular_Full_Version/js/plugins/metisMenu/jquery.metisMenu.js"/>"></script>
<!-- SlimScroll -->
<script href="<c:url value="/Angular_Full_Version/js/plugins/slimscroll/jquery.slimscroll.min.js"/>"></script>
<!-- Peace JS -->
<script href="<c:url value="/Angular_Full_Version/js/plugins/pace/pace.min.js"/>"></script>
<!-- Custom and plugin javascript -->
<script href="<c:url value="/Angular_Full_Version/js/inspinia.js"/>"></script>
<!-- Main Angular scripts-->
<script href="<c:url value="/Angular_Full_Version/js/angular/angular.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/angular/angular-sanitize.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/plugins/oclazyload/dist/ocLazyLoad.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/angular-translate/angular-translate.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/ui-router/angular-ui-router.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/bootstrap/ui-bootstrap-tpls-1.1.2.min.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/plugins/angular-idle/angular-idle.js"/>"></script>
<!--
You need to include this script on any page that has a Google Map.
When using Google Maps on your own site you MUST signup for your own API key at:
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
After your sign up replace the key in the URL below..
-->
<script type="text/javascript" href="<c:url value="/https://maps.googleapis.com/maps/api/js?key=AIzaSyDQTpXj82d8UpCi97wzo_nKXL7nYrd4G70"/>"></script>
<!-- Anglar App Script -->
<script href="<c:url value="/Angular_Full_Version/js/app.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/config.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/translations.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/directives.js"/>"></script>
<script href="<c:url value="/Angular_Full_Version/js/controllers.js"/>"></script>
</body>
</html>
todo-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" 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-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="com.craftinggamertom" />
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<mvc:interceptors>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="language" />
</bean>
</mvc:interceptors>
<mvc:resources mapping="/Angular_Full_Version/**" location="/style" />
<mvc:resources mapping="/Angular_Full_Version/css/**" location="/style" />
<mvc:resources mapping="/Angular_Full_Version/js/**" location="/style" />
</beans>
web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>To do List</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/todo-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<error-page>
<location>/WEB-INF/views/error.jsp</location>
</error-page>
</web-app>
最佳答案
解决方案1
如果您确实需要文件夹结构中的 style
那么您可以执行以下操作:
删除所有
<mvc:resources />
标签和以下标签:<mvc:resources mapping="/style/**" location="/style/" />
然后将
/style
添加到所有链接,如下所示:<script href="<c:url value="/style/Angular_Full_Version/js/app.js"/>"></script>
解决方案2
您可以删除 style
文件夹,添加上一级 Angular_Full_Version
文件夹。 (这是我的建议,因为我发现您正在关注 Angular_Full_Version
文件夹。按照此操作:
- 复制
Angular_Full_Version
文件夹并将其粘贴到webapp
文件夹下,然后删除style
文件夹。 删除所有
<mvc:resources />
标签和以下标签:<mvc:resources mapping="/Angular_Full_Version/**" location="/Angular_Full_Version/" />
最佳实践(我在不同的博客中找到)
resources
文件夹下应该有一个名为WEB-INF
的文件夹。在resources
文件夹下包含images
、js
、css
等所有资源。那么
mvc:resources
就像:<mvc:resources mapping="/resources/**" location="/resources/" />
使用时:
<script href="<c:url value="/resources/js/app.js"/>"></script>
关于java - Spring框架映射/处理 "Did not find handler method",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45520268/