美文网首页
SpringMVC配置文件

SpringMVC配置文件

作者: 账号已被注销 | 来源:发表于2019-07-05 22:18 被阅读0次
    <?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:jdbc="http://www.springframework.org/schema/jdbc"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    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/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
    http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-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/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
    
    <!-- 加载组件扫描 -->
    <context:component-scan base-package="controller"/>
    
    <!-- 可指定某一个类为Controller处理类(不是必须) -->
    <bean name="/HelloKitty" class="controller.TestController2"/>
    
    <!-- 解决 @responsebody注解返回中文乱码问题 -->
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
            <property name="messageConverters">
                    <list>
                            <bean id="stringHttpMessageConverter" class="org.springframework.http.converter.StringHttpMessageConverter">
                                    <property name="writeAcceptCharset" value="true" />
                                    <property name="supportedMediaTypes" >
                                            <list>
                                                    <value>application/json;charset=UTF-8</value>
                                            </list>
                                    </property>
                            </bean>
                    </list>
            </property>
    </bean>
    <!-- 开启静态资源访问 -->
    <mvc:default-servlet-handler />
    <!-- 配置MVC注解扫描 -->
    <mvc:annotation-driven />
    
    <!-- 配置视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/WEB-INF/page/"></property>
            <property name="suffix" value=".jsp"></property>
    </bean>
    </beans>
    

    相关文章

      网友评论

          本文标题:SpringMVC配置文件

          本文链接:https://www.haomeiwen.com/subject/nqiyhctx.html