|
<?xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<!-- 指定註解掃描包 掃描使用了註解的類 Spring在啟動的時候,會預設掃描自動掃描包下的所有的類,
為每個註解分配一個mapping。 -->
<context:component-scanbase-package="com.morris.controller"></context:component-scan>
<!-- AnnotationMethodHandlerAdapter是方法映射的,不同方法有不同url請求,在類找方法。
2)DefaultAnnotationHandlerMapping
DefaultAnnotationHandlerMapping根據掃描的包下面找類,即通過url找類 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"></bean>
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"></bean>
<!-- 視圖解析器 當返回邏輯視圖時,InternalResourceViewResolver會加上首碼和尾碼 -->
<beanid="internalResourceViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<propertyname="suffix"value=".jsp"></property>
<propertyname="prefix"value="/"></property>
</bean>
</beans> |