zoukankan      html  css  js  c++  java
  • springmvc-servlet.xml 第二种选择

    <?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:aop="http://www.springframework.org/schema/aop"
    	xmlns:mvc="http://www.springframework.org/schema/mvc" 
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
           	http://www.springframework.org/schema/aop 
           	http://www.springframework.org/schema/aop/spring-aop-3.0.xsd  
           	http://www.springframework.org/schema/tx 
           	http://www.springframework.org/schema/tx/spring-tx-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"
           	>
        <!-- 启动注解启动 -->
        <mvc:annotation-driven/>
        <!-- 启动组件扫描器 -->
        <context:component-scan base-package="com"/>
        
    	<!-- 视图解析器  配置前缀和后缀 要据modelAndView中封装视图名找到目标页面-->
    	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix" value="/view/"></property>
    		<property name="suffix" value=".jsp"></property>
    	</bean>
    	
    	<bean name="/hello.do" class="com.jah.dm700.springmvc.hello.HelloController"/>
    	
    	<!-- 映射器配置 表示将name属性作为url请求 默认配置,可以不配置-->
    	<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
    	
    	<!-- 适配器配置 用于寻找实现了Controller接口的action类  默认配置  可以不配置-->
    	<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
    	
    	<bean name="/dt.do" class="com.jah.dm701.springmvc.adv.DateController"/>
    	
    	<!-- 从请求到响应读出数据 -->
    	<bean id="stringConvert" class="org.springframework.http.converter.StringHttpMessageConverter">
    		<property name="supportedMediaTypes">
    			<list>
    				<value>text/plain;charset=UTF-8</value>
    			</list>
    		</property>
    	</bean>
    	<!-- 对象转换成json -->
    	<bean id="jsonConvert" 
    		class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
    	<!-- 注解适配器 -->
    	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    		<property name="messageConverters">
    			<list>
    				<ref bean="stringConvert"/>
    				<ref bean="jsonConvert"/>
    			</list>
    		</property>
    	</bean>
    </beans>
    

      

  • 相关阅读:
    ie浏览器下,get请求缓存问题
    grunt 单独压缩多个js和css文件【转】
    初次接触nodejs,请多指教。
    浮躁是一种流行病【转】
    php安装配置那些事(本文纯属个人记事与技术无关)
    读取年份数组中的所有周六周天
    C#窗体中读取修改xml文件
    Power BI brief introduction
    D365 CRM online trial application
    TalkingData Cocos2dx集成指南【最新】
  • 原文地址:https://www.cnblogs.com/1020182600HENG/p/6725081.html
Copyright © 2011-2022 走看看