xml configuration file of springmvc

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
		http://www.springframework.org/schema/mvc
		http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
		http://www.springframework.org/schema/context
		http://www.springframework.org/schema/context/spring-context-3.2.xsd
		http://www.springframework.org/schema/aop
		http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
		http://www.springframework.org/schema/tx
		http://www.springframework.org/schema/tx/spring-tx-3.2.xsd ">

	<!-Deployment Handler->
	<bean id="itemsController1" name="/queryItems_test.action" class="cn.itcast.ssm.controller.ItemsController1" />
	<!-- Configure another Handler -->
	<bean id="itemsController2" class="cn.itcast.ssm.controller.ItemsController2" />
	
	<!-- Annotated Handlers can be configured individually
	It is recommended to use component scanning in actual development
	 -->
	<!-- <bean class="cn.itcast.ssm.controller.ItemsController3" /> -->
	<!-- Can scan for controller, service, ...
	Here let's scan the controller and specify the controller's package
	 -->
	<context:component-scan base-package="cn.itcast.ssm.controller"></context:component-scan>
	
	
	<!-- The handler mapper looks up the bean's name as the url. You need to specify the beanname (that is, the url) when configuring the Handler.
	All mappers implement the HandlerMapping interface.
	-->
	<bean
		class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
		
	<!--Simple url mapping-->
	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
		<property name="mappings">
			<props>
				<!-- Perform url mapping on itemsController1, the url is /queryItems1.action -->
				<prop key="/queryItems1.action">itemsController1</prop>
				<prop key="/queryItems2.action">itemsController1</prop>
				<prop key="/queryItems3.action">itemsController2</prop>
			</props>
		</property>
	</bean>
	
	<!--Annotation mapper-->
	<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
	<!--Annotation Adapter-->
	<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
	
	<!-- Use mvc:annotation-driven instead of the above annotation mapper and annotation adapter configuration
	mvc:annotation-driven loads many parameter binding methods by default,
	For example, the json conversion parser is loaded by default. If you use mvc:annotation-driven, you do not need to configure the RequestMappingHandlerMapping and RequestMappingHandlerAdapter above.
	Use mvc:annotation-driven in actual development
	 -->
	<!-- <mvc:annotation-driven></mvc:annotation-driven> -->
	

	<!-- Handler Adapters All handler adapters implement the HandlerAdapter interface -->
	<bean
		class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
	<!-- Another non-annotated adapter -->
	<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"/>

	<!-- view resolver
	Parsing jsp parsing, the default jstl tag is used, and the jstl package must be in the classpath
	 -->
	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<!-- Configure the prefix of the jsp path -->
		<property name="prefix" value="/WEB-INF/jsp/"/>
		<!-- Configure the suffix of the jsp path -->
		<property name="suffix" value=".jsp"/>
	</bean>
</beans>
From Dark Horse Programmer

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325534927&siteId=291194637