Java spring资源映射不工作
目前我在一个spring项目中工作。当我试图从资源文件夹访问样式表时,出现了一个“未找到资源”错误。我使用mvc:resource mapping映射了资源文件夹。以下是我的代码:Java spring资源映射不工作,java,css,spring,jsp,model-view-controller,Java,Css,Spring,Jsp,Model View Controller,目前我在一个spring项目中工作。当我试图从资源文件夹访问样式表时,出现了一个“未找到资源”错误。我使用mvc:resource mapping映射了资源文件夹。以下是我的代码: <mvc:resources mapping="/resources/**" location="/WEB-INF/resourcs/" /> 在我的jsp页面中: <link rel="stylesheet" type="text/css" href="<c:url v
<mvc:resources mapping="/resources/**" location="/WEB-INF/resourcs/" />
在我的jsp页面中:
<link rel="stylesheet" type="text/css"
href="<c:url value='/resources/css/login.css'/>">
调度程序Servlet:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd ">
如果您需要我的项目中更具体的代码,请让我知道。检查此处的资源文件夹名称
这里的那个
希望它能解决这个问题 我想有个拼写错误。应该是这样的:
<mvc:resources mapping="/resources/**" location="/WEB-INF/resources/" />
如果这不能解决问题,请告诉我。最后我自己清除了它。 这只是版本问题,不是冲突。我将我的spring版本从4.2.1版更改为4.2.2版。这似乎是版本中的一个bug
谢谢可能有输入错误:
resourcas
(缺少e
)。如果这不是问题的原因,请将“org.springframework”日志设置为DEBUG,再次启动页面并发布日志您是对的,我修复了问题,但eclipse控制台中显示了一个错误,浏览器中显示了一个500错误控制台中的错误原因是javax.servlet.http.HttpServletResponse.getHeader(Ljava/lang)/String;)Ljava/lang/Str
从href
中删除/resource
最后我遇到了这个错误java.lang.NoSuchMethodError:javax.servlet.http.HttpServletResponse.getHeader(Ljava/lang/String;)Ljava/lang/String;我怎样才能解决这个问题?你能帮我吗?请把所有的例外情况都贴出来。就这一句话我什么也说不出来。这可能是由于拼写错误、编译时环境与运行时环境不匹配或配置问题造成的;org.springframework.web.context.request.ServletWebRequest.checkNotModified(ServletWebRequest.java:187)org.springframework.web.servlet.ResourceHttpRequestHandler.HandlerRequest(ResourceHttpRequestHandler.java:240)org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)在org.springframeworkframeworkervlet.doGet(FrameworkServlet.java:861)位于javax.servlet.http.HttpServlet.service(HttpServlet.java:617)位于org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)位于javax.servlet.http.HttpServlet.service(HttpServlet.java:717)最后,我遇到了这个错误java.lang.NoSuchMethodError:javax.servlet.http.HttpServletResponse.getHeader(Ljava/lang/String;)Ljava/lang/String;我如何解决这个问题?你能帮我吗?我也有同样的错误,但我在做JAXB。我想你应该检查spring配置文件中的xsd映射。我用我的dispatcher servlet更新了我的问题,请检查它