<?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>

  

springmvc-servlet.xml 第二种选择的更多相关文章

  1. Web---创建Servlet的3种方式、简单的用户注册功能

    说明: 创建Servlet的方式,在上篇博客中,已经用了方式1(实现Servlet接口),接下来本节讲的是另外2种方式. 上篇博客地址:http://blog.csdn.net/qq_26525215 ...

  2. SpringMVC实现操作的第二种方式

    一: 运行效果: 点击提交之后显示效果 二: (1).web.xml <?xml version="1.0" encoding="UTF-8"?> ...

  3. springmvc的xml版本和注解版本

    感觉还是注解方式比较实用 xml方式 web.xml <!-- 读取spring mvc的核心配置文件 --> <servlet> <servlet-name>yx ...

  4. 创建servlet的三种方式

    第一种方式,实现Servlet接口 package com.example.servlet; import java.io.IOException; import javax.servlet.Serv ...

  5. springmvc 项目完整示例07 设置配置整合springmvc springmvc所需jar包springmvc web.xml文件配置

    前面主要是后台代码,spring以及mybatis的整合 下面主要是springmvc用来处理请求转发,展现层的处理 之前所有做到的,完成了后台,业务层和持久层的开发完成了 接下来就是展现层了 有很多 ...

  6. SpringBoot整合Servlet的两种方式

    SpringBoot整合Servlet有两种方式: 1.通过注解扫描完成Servlet组件的注册: 2.通过方法完成Servlet组件的注册: 现在简单记录一下两种方式的实现 1.通过注解扫描完成Se ...

  7. springmvc web.xml配置之 -- DispatcherServlet

    springMVC servlet配置与启动 看一下springmvc的web.xml常见配置: <servlet> <!-- 配置DispatcherServlet --> ...

  8. 返回Json和XML两种格式

    由于项目需要,同一接口支持根据参数不同返回XML和Json两种格式的数据,在网上看了很多大多是加后缀的方式来实现返回不同格式数据的,后来看了一篇http://www.importnew.com/276 ...

  9. Tomcat配置文件之servlet.xml中选项介绍

    Servlet.xml 分为以下元素: server, service, Connector ( 表示客户端和service之间的连接), Engine ( 表示指定service 中的请求处理机,接 ...

随机推荐

  1. 转:Python结合P有winauto进行windows UI自动化

    https://blog.csdn.net/z_johnny/article/details/52778064

  2. C++多个文本读取问题

    同时使用两个 ifstream和 freopen 第二个就会失去效用,不知道错在了哪里! 1. 使用freopen打开: bool CPicToolsDlg::readTxt2Seq( std::st ...

  3. 程序员客栈与DaoCloud这两家企业联手后,运维工程师要失业了!

    2017年1月11日 ,程序员客栈与DaoCloud正式建立合作伙伴关系,为创业企业和团队提供容器应用解决方案.通过与DaoCloud合作,客栈可以更有效地把控开发环节中的不确定因素,解决项目工期不确 ...

  4. Ad hoc polymorphism

    与面向对象中的接口类或抽象类中定义的函数组类似: 函数的具体执行依赖与函数医用的类型. In programming languages, ad-hoc polymorphism[1] is a ki ...

  5. https ssl 总结

    主要工作: 1)算法协商: 2)密钥交换: 3)身份认证: 4)数据通信: 1.2.3主要使用握手协议: 4使用记录协议. SSL协议可分为两层:记录协议.握手协议 SSL Record Protoc ...

  6. Python——Numpy基础知识(一)

    一.Numpy的引入 1.标准的Python 中用列表(list)保存一组值,可以当作数组使用.但由于列表的元素可以是任何对象,因此列表中保存的是对象的指针.对于数值运算来说,这种结构显然比较浪费内存 ...

  7. Context、Select(day01)

    Oracle sql: 4天 plsql: 2天 proc: 2天 数据库介绍 1.1 数据库简介 1.1.1 数据管理技术的发展 人工管理阶段:20世纪50年代中期之前 文件管理阶段:20世纪的50 ...

  8. 51Nod - 1134 最长递增子序列【动态规划】

    给出长度为N的数组,找出这个数组的最长递增子序列.(递增子序列是指,子序列的元素是递增的) 例如:5 1 6 8 2 4 5 10,最长递增子序列是1 2 4 5 10. Input 第1行:1个数N ...

  9. python-写入csv 文件

    项目要做一个导出客户信息的功能,需要写入csv: 注意文件写入的方式  例如   write open(‘w’) 从头开始写,之前写的会被替换  write open(‘a’) 则代表追加,文件指针放 ...

  10. 【例题4-2 uva489】Hangman Judge

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 水题. 中间就赢了算赢.(重复说,算错 [代码] #include <bits/stdc++.h> using name ...