当前位置: 首页 > 知识库问答 >
问题:

在spring mvc中添加css文件

子车劲
2023-03-14

我的spring-servlet.xml

<?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:p="http://www.springframework.org/schema/p"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:mvc="http://www.springframework.org/schema/mvc"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/mvc 
 http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 <mvc:resources mapping="/resources/**" location="/WEB-INF/resources/" /> 
 <context:component-scan  base-package="com.arobol.controller" /> 
  <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
     <property name="prefix" value="/WEB-INF/jsp/" />  
     <property name="suffix" value=".jsp" />  
  </bean>
</beans>

共有1个答案

鞠宏恺
2023-03-14

确保xml文件的xml模式与spring版本相对应,因此对于Spring3.0应该类似于

<?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:context="http://www.springframework.org/schema/context"
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

stacktrace问题说

Configuration problem: Cannot locate BeanDefinitionParser for element [resources] Offending resource: ServletContext resource [/WEB-INF/spring-servlet.xml] 

看起来像是JAR和包含的模式不匹配

<?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:context="http://www.springframework.org/schema/context"
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xsi:schemaLocation="
      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
      http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
 类似资料:
  • 我使用intelliJ IDEA中的maven webapp原型创建了一个spring项目。我正在使用tomcat插件和maven插件。我可以在app name/home路径上运行这个应用程序,但是css和图像没有加载,它显示的是简单的文本和图像表情。 在项目内部,我创建了ApplicationInitializer类,这很好,ApplicationConfig看起来像这样- 下面是文件夹结构-

  • 问题内容: 我正在尝试使用mpdf将html转换为pdf。问题是我无法将CSS应用于pdf文件。 这是我的php代码: 它在做什么是在我的此php页面上通过ajax提取html。但是它给出的输出并不带有我为此编写的css。 请告诉我现在要做吗? 问题答案: 首先分配您的html,然后包含 mpdf.php 文件。

  • 问题内容: 我正在创建一个popupwindow,我想向该popupwindow中添加一个css文件,下面是popupwindow的代码。我有创建一个popupwindow的JavaScript。 现在,我想向该popupwindow中添加一个CSS文件。我尝试了类似的东西 但不起作用。 谢谢 问题答案: 这应该工作。

  • 请看下面的JavaFX和CSS代码。 登录2。JAVA 我ogin.css 当我运行这个,我得到以下错误。 应用程序启动方法中的异常线程“main”java中的异常。lang.RuntimeException:com上应用程序启动方法中的异常。太阳javafx。应用发射装置impl。在com上启动Application1(未知源)。太阳javafx。应用发射装置impl。在com上访问$000(未

  • 问题内容: 我的网站顶部菜单中有外部链接。我想在新标签页中打开这些链接。我可以在HTML中使用“ target = _blank”来实现。 是否有类似的CSS属性或其他属性? 问题答案: 抱歉不行。在2013年,无法使用纯CSS做到这一点。 更新 :感谢showdev链接到CSS3 Hyperlinks的过时规范,是的,没有浏览器实现它。因此,答案仍然有效。

  • 问题内容: 我正在使用ejs在node.js(express)上工作,并且无法在其中包含.css文件。我分别尝试了与html- css二重奏相同的事情,并且效果很好…我如何在其中包含相同的内容我的.ejs文件。我的app.js因此: 和index.ejs文件: style.css文件: 问题答案: 您的问题实际上并非特定于ejs。 这里要注意的两件事 style.css 是一个外部css文件。因此