Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 资源共享在spring mvc应用程序中不起作用_Java_Spring_Web_Model View Controller_Resources - Fatal编程技术网

Java 资源共享在spring mvc应用程序中不起作用

Java 资源共享在spring mvc应用程序中不起作用,java,spring,web,model-view-controller,resources,Java,Spring,Web,Model View Controller,Resources,我创建了一个Spring MVC Web应用程序,它运行良好。然后我决定改进UI,并添加CSS文件和图像,但它们没有被提供。 如果我不在代码中添加任何css或图像,那么这个应用程序运行得非常好。 这是我的servlet配置文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.

我创建了一个Spring MVC Web应用程序,它运行良好。然后我决定改进UI,并添加CSS文件和图像,但它们没有被提供。 如果我不在代码中添加任何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:mvc="http://www.springframework.org/schema/mvc"
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/beans">

<context:property-placeholder location="classpath:/database.properties"/>
<context:component-scan base-package="com.aakash.em" />
<tx:annotation-driven transaction-manager="hibernateTransactionManager" />

<!-- View resolver -->
<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/" />
    <property name="suffix" value=".jsp" />
</bean>

 <bean class="org.springframework.orm.hibernate3.HibernateTransactionManager" 
 id="hibernateTransactionManager">
   <property name="sessionFactory" ref="sessionFactory"></property>
 </bean>

  <mvc:resources mapping="/resources/**" location="/resources/" cache-period="31556926" />
  <mvc:default-servlet-handler/>
</beans>

这是我的web.xml

<web-app id="WebApp_ID" version="2.4" 
    xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Spring Hibernate Employee Management System</display-name>
    <servlet>
      <servlet-name>spring</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/config/dispatcher-servlet.xml</param-value>
     </init-param>
     <load-on-startup>1</load-on-startup>
   </servlet>
  <servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
</web-app>

springhibernate员工管理系统
春天
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/config/dispatcher-servlet.xml
1.
春天
*.html
这是我的目录结构


向我们展示如何在代码中使用图像/css?也许这就是问题所在