费马小定理 2017-05-06 02:42 采纳率: 100%
浏览 1887
已采纳

ssm框架静态文件引入报404,求大神指点

这是我的SpringMVC配置文件的一些信息:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

<!-- 使spring扫描包下的所有类,让标注spring注解的类生效 -->
<context:component-scan base-package="cn.beike"/>

<!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/pages/"/>
    <property name="suffix" value=".jsp"/>
</bean>



<mvc:resources mapping="/images/**" location="/images/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
<mvc:resources mapping="/css/**" location="/css/" />

<mvc:default-servlet-handler />

这是控制台输出的一些信息:

  • (1440675 ms) - [DEBUG] 2017-05-06 10:32:29,019 org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'spring' processing GET request for [/Real_estate/login.action]
  • (1440677 ms) - [DEBUG] 2017-05-06 10:32:29,021 org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Matching patterns for request [/login.action] are [/**]
  • (1440678 ms) - [DEBUG] 2017-05-06 10:32:29,022 org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - URI Template variables for request [/login.action] are {}
  • (1440679 ms) - [DEBUG] 2017-05-06 10:32:29,023 org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapping [/login.action] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler@69d64cf4] and 1 interceptor
  • (1440680 ms) - [DEBUG] 2017-05-06 10:32:29,024 org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/Real_estate/login.action] is: -1
  • (1440681 ms) - [DEBUG] 2017-05-06 10:32:29,025 org.springframework.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'spring': assuming HandlerAdapter completed request handling
  • (1440682 ms) - [DEBUG] 2017-05-06 10:32:29,026 org.springframework.web.servlet.DispatcherServlet - Successfully completed request

这是web.xml的配置信息:

<?xml version="1.0" encoding="UTF-8"?>
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">

<!-- 指定Spring Bean的配置文件所在目录。默认配置在WEB-INF目录下 -->

contextConfigLocation
classpath:applicationContext-*.xml

<!-- spring字符编码过滤器start-->
<filter>
    <!--① Spring 编码过滤器 -->
    <filter-name>encodingFilter</filter-name>
    <filter-class>
        org.springframework.web.filter.CharacterEncodingFilter
    </filter-class>
    <!--② 编码方式  -->
    <init-param> 
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <!--③ 强制进行编码转换 -->
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<!-- ② 过滤器的匹配 URL -->
<filter-mapping> 
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<!-- spring字符编码过滤器end-->


<!-- Spring MVC配置 -->
<!-- ====================================== -->
<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>



<!-- Spring配置 -->
<!-- ====================================== -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- log4j配置start -->
<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>classpath:log4j.properties</param-value>
</context-param>
<!-- Spring 加载 Log4j 的监听 -->
<listener>
    <listener-class>
        org.springframework.web.util.Log4jConfigListener
    </listener-class>
</listener>
<!-- log4j配置end -->



<!--  


default
.jpg


default
.gif


default
.png


default
.js


default
*.css

-->


index.jsp


  • 写回答

4条回答 默认 最新

  • 坎特 2017-05-06 05:44
    关注

    web.xml 里加这些标签


    default
    .css


    default
    .jpg


    default
    .jpeg


    default
    .png


    default
    .js


    default
    .woff


    default
    *.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集