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:aop="http://www.springframework.org/schema/aop"   
    xmlns:context="http://www.springframework.org/schema/context"  
    xmlns:jee="http://www.springframework.org/schema/jee"  
    xmlns:tx="http://www.springframework.org/schema/tx"  
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="    
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd  
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
        http://www.springframework.org/schema/mvc   http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd  
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd  
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">    

	
	<!-- 要使用spring mvc中的@Controller註解,就必須要配置<mvc:annotation-driven />,否則org.springframework.web.servlet.DispatcherServlet無法找到控制器並把請求分發到控制器。 -->
	<!-- 默認的註解映射的支持 ,它會自動註冊DefaultAnnotationHandlerMapping 與AnnotationMethodHandlerAdapte爲bean -->
	<mvc:annotation-driven></mvc:annotation-driven>
	
	<!-- 靜態資源映射 -->
	<mvc:resources mapping="/static/**" location="/static/"/>

	<!-- 配置視圖解析器,即如何把handler方法返回值解析爲實際的物理視圖  -->
	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/" />
		<property name="suffix" value=".jsp"></property>
	</bean>
	<!-- 實現文件上傳的的form中還要添加'enctype="multipart/form-data' 這條屬性-->
	<bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		
		<property name="defaultEncoding" value="UTF-8"/>  
	    <property name="maxUploadSize" value="10000000"/>

	</bean>

	<!-- 使用註解的包,包括子集 -->
	<context:component-scan base-package="com.java.controller" />
</beans>  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章