使用springMVC搭建后台,想实现拦截所有后缀的请求,怎么办

256 阅读1分钟

以下是web.xml配置文件内容:

Archetype Created Web Application encodingFilter org.springframework.web.filter.CharacterEncodingFilter true encoding UTF-8 encodingFilter /*

<!-- ======================================================== -->
<!-- Spring MVC Config Servlet -->
<!-- ======================================================== -->
<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:spring-mvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- ======================================================== -->
<!-- Spring MVC Config Mapping -->
<!-- ======================================================== -->
<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:component-scan base-package="com.soft.webapp.**.controller"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan>

 <mvc:annotation-driven></mvc:annotation-driven>

<!-- 定义跳转的文件的前后缀 ,视图模式配置 -->
<bean  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/view/" />
    <property name="suffix" value=".html" />
    <property name="contentType" value="text/html;charset=UTF-8" />
    <property name="order" value="0" />
</bean>

我还需要修改哪个地方或者追加那些配置才能实现我想要的效果??现在是控制器返回页面的时候被拦截了,怎么处理求大佬指点