Spring MVC
@web.xml config mapper one {serlvet-Name}-serlvet.xml
web.xml配置解析:
HiddenHttpMethodFilter是针对浏览器表单不支持put和delete方法而设计 的,通过在表单中设置隐藏域,来发布到相应的处理器上,如<input type="hidden" name="_method" value="put"/>
ajax提交的put请求,无法通过HiddenHttpMethodFilter这个过滤器拿到值,需要用HttpPutFormContentFilter。
encoding filter:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<filter> <filter-name>encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding</filter-name> <servlet-name>springapp</servlet-name> </filter-mapping> <servlet> <servlet-name>springapp</servlet-name> <servlet-class>com.astasys.servlet.common.spring.MultiMethodDispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springapp</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>springapp</servlet-name> <url-pattern>/webdav/*</url-pattern> </servlet-mapping>
context loader:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:applicationContext.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listenercon
@MultiActionController&MethodNameResolver configure
ParameterMethodNameResolver
InternalPathMethodNameResolver
PropertiesMethodNameResolver
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/pages/" /> <property name="suffix" value=".jsp" /> </bean>
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="interceptors"> <list> <bean class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor"> <property name="sessionFactory" ref="sessionFactory" /> <property name="singleSession" value="true" /> </bean> <ref bean="localeChangeInterceptor" /> <ref bean="responseHandlerInterceptor" /> <ref bean="authenticationEventInterceptor" /> </list> </property> <property name="urlMap"> <map> <entry key="/webdav" value-ref="webdavController" /> <entry key="/webdav/**" value-ref="webdavController" /> <entry key="/**/checkoutFiles.htm"> <bean parent="simpleMultiActionWrapper" class="com.astasys.dms.coeus.controller.CheckoutController"> <property name="successView" value="CheckoutResultPage" /> <property name="failureView" value="CheckoutResultPage" /> </bean> </entry> <entry key="/**/sentbox.htm"> <bean class="com.astasys.dms.coeus.controller.SentItemController" parent="simpleMultiActionWrapper"> <property name="sentItemView" value="ListSentItem" /> </bean> </entry> </map> </property> </bean>
<bean id="urlHandlerPapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/b/*"><ref bean="bController"></ref></entry>
</map>
</property>
</bean>
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<bean id="bMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"> <property name="paramName" value="methodToCall" /> <property name="defaultMethodName" value="defaultAction" /> <property name="logicalMappings"> <props> <prop key="dosearch">dosearch</prop> </props> </property> </bean> <bean id="cMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver"> </bean> <bean id="dMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.PropetiesMethodNameResolver"> <property name="mapping"> <value>/b/page.html=dosearch</value> </bean>
1.把controller发在handlerMapping里
2.把controller的ref属性指向特定的handlerMapping