首页 > Spring > 正文

springMVC配置

标签:Spring

springMVC配置

<?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:p="http://www.springframework.org/schema/p"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
   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">
<!-- more -->
<context:component-scan base-package="com.lyf" annotation-config="true"/>

<bean id="jspViewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="viewClass"
			value="org.springframework.web.servlet.view.JstlView" />
		<property name="prefix" value="/jsp/" />
		<property name="suffix" value=".jsp" />
	</bean>

<mvc:annotation-driven>
    <mvc:message-converters>
	
	    <bean class="org.springframework.http.converter.StringHttpMessageConverter">
	    <property name="supportedMediaTypes">
		    <list>
			    <value>text/plain;charset=UTF-8</value>
			    <value>text/html;charset=UTF-8</value>
		    </list>
	    </property>
	    </bean>
	    <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
		    <property name="supportedMediaTypes">
			    <list>
			    	<value>application/json;charset=UTF-8</value>
			    </list>
		    </property>
	    </bean>
    </mvc:message-converters>
</mvc:annotation-driven>



    <!-- 文件上传 -->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="maxUploadSize" value="10485760"/> <!-- 10m -->
    <property name="maxInMemorySize" value="4096" />
    <property name="defaultEncoding" value="UTF-8"></property>
    </bean>


</beans>

上篇: Jekyll站内搜索