dispatcher-servlet.xml文件配置模板
阅读原文时间:2023年07月10日阅读:1

完整代码如下:


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">



<!--开通静态资源的访问,即jsp或html文件-->  
<mvc:default-servlet-handler/>  
<!--让所有的Controller能够解析,不可缺少,<mvc:annotation-driven>里面那一整段,用来解决@ResponseBody传输字符串中文乱码问题-->  
<mvc:annotation-driven>  
    <mvc:message-converters>  
        <bean class="org.springframework.http.converter.StringHttpMessageConverter">  
            <property name="supportedMediaTypes">  
                <list>  
                    <value>application/json;charset=UTF-8</value>  
                </list>  
            </property>  
        </bean>  
    </mvc:message-converters>  
</mvc:annotation-driven>  
<!-- 视图解析器/定位 -->  
<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
    <!-- 配置前缀 -->  
    <property name="prefix" value="/WEB-INF/jsp/"/>  
    <!-- 配置后缀 -->  
    <property name="suffix" value=".jsp"/>  
</bean>  
<!--文件上传  -->  
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>  

部分截图如下: