Java教程

Java SSM整合Springmvc.xml配置文件

本文主要是介绍Java SSM整合Springmvc.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: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
">

   <!-- &lt;!&ndash;配置权限拦截器&ndash;&gt;
    <mvc:interceptors>
        <mvc:interceptor>
            &lt;!&ndash;配置对哪些资源执行拦截操作&ndash;&gt;
            <mvc:mapping path="/**"/>
            &lt;!&ndash;配置哪些资源排除拦截操作&ndash;&gt;
            &lt;!&ndash;
                <mvc:exclude-mapping path="/"/>:表示允许/通过 ==>  访问/的时候会自动找到index
                    因为:<mvc:view-controller path="/" view-name="index"></mvc:view-controller>

               <mvc:exclude-mapping path="/login"/>:表示允许/login通过==>
                     当单击index.html中的提交按钮时就会访问ManagerController类中的/login进行登录判断
            &ndash;&gt;
            <mvc:exclude-mapping path="/"/>
            <mvc:exclude-mapping path="/login"/>
            <mvc:exclude-mapping path="/static"/>
            <bean class="com.hsx.interceptor.LoginInterceptor"/>
        </mvc:interceptor>
    </mvc:interceptors>-->

    <!--配置包扫描:只扫描controller-->
    <context:component-scan base-package="com.learn.controller" use-default-filters="false">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>

    <!--配置Thymeleaf视图解析器-->
    <!--<bean id="viewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver">
        <property name="order" value="1"/>
        <property name="characterEncoding" value="UTF-8"/>
        <property name="templateEngine">
            <bean class="org.thymeleaf.spring5.SpringTemplateEngine">
                <property name="templateResolver">
                    <bean class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
                        &lt;!&ndash; 视图前缀 &ndash;&gt;
                        <property name="prefix" value="/WEB-INF/templates/"/>
                        &lt;!&ndash; 视图后缀 &ndash;&gt;
                        <property name="suffix" value=".html"/>
                        <property name="templateMode" value="HTML5"/>
                        <property name="characterEncoding" value="UTF-8"/>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>-->

    <!--不配置此物无法访问静态资源-->
    <!--<mvc:view-controller path="/" view-name="index"></mvc:view-controller>
    <mvc:view-controller path="/list" view-name="list"></mvc:view-controller>-->

    <!--两个标准配置  -->
    <!-- 将springmvc不能处理的请求交给tomcat -->
    <mvc:default-servlet-handler/>

    <!-- 能支持springmvc更高级的一些功能,JSR303校验,快捷的ajax...映射动态请求 -->
    <mvc:annotation-driven/>

</beans>
这篇关于Java SSM整合Springmvc.xml配置文件的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!