ainideaj
ainideaj
采纳率0%
2016-05-20 09:51 阅读 1.4k

spring 4.2.6 mvc 静态资源访问问题

![新进公司, 尝试自己重新拾起搭一个springmvc框架,可是一个静态资源访问问
题拦住了我两天,求大神帮忙:

图片说明](https://img-ask.csdn.net/upload/201605/20/1463737807_800158.png)
这是使用jar包

图片说明

web.xml 配置:


springmvc

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:config/application*.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:config/spring-mvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

spring-mvc.xml配置:

<context:annotation-config />

<mvc:annotation-driven />

<mvc:resources mapping="/views/ui/**" location="/WEB-INF/views/ui/" />
<mvc:resources mapping="/views/new_ui/**" location="/WEB-INF/views/new_ui/" />

<context:component-scan base-package="com.aj.store" />

<!-- 完成请求和注解POJO的映射 -->
<bean
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

<!-- 对模型视图添加前后缀 -->
<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver"
    p:prefix="/WEB-INF/views/" p:suffix=".html" />

在网上搜了很多解决办法, 什么tomcat default 配置

等都试过。。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐