springMVC_注解方式搭建基础环境
---恢复内容开始---
一、jar包环境,web配置文件和Spring-MVC配置文件的,相关的modelAndview

1.配置DispatcherServlet
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
2.配置bean.xml文件的监听器
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
3.配置Spring-MVC.xml文件
3.1配置扫描控制器Cotroller包路径和注解驱动
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 ">
<!-- 自动扫描 -->
<context:component-scan base-package="springmvcpractice\web\controller">
</context:component-scan>
<mvc:resources location="/resources/" mapping="/images/**"/>
<!-- 注解驱动 -->
<mvc:annotation-driven>
</mvc:annotation-driven>
3.2配置文件上传解析器
<!-- 文件上传解析器 id 必须为multipartResolver -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="10485760">
</property>
</bean>
3.3配置内部资源解析器和静态视图资源路径
<!-- 映射静态资源 -->
<mvc:resources location="/images/" mapping="/images/**"/>
<mvc:resources location="/upload/" mapping="/upload/**"/>
<!-- 内部资源视图解析器 prefix + logicName + suffix /WEB-INF/jsps/ + index + .jsp-->
<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/jsps/"/>
<!-- 后缀 -->
<property name="suffix" value=".jsp"/>
</bean>
3.4配置beans.xml文件的Service包路径的自动扫描
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
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 ">
<!-- 自动扫描 -->
<context:component-scan base-package="springmvcpractice\service"/>
</beans>
二、配置编写,person bean,personService和contorller的实体类



三、
---恢复内容结束---
springMVC_注解方式搭建基础环境的更多相关文章
- JAVA配置&注解方式搭建简单的SpringMVC前后台交互系统
前面两篇文章介绍了 基于XML方式搭建SpringMVC前后台交互系统的方法,博文链接如下: http://www.cnblogs.com/hunterCecil/p/8252060.html htt ...
- 使用注解方式搭建SpringMVC
1.以前搭建Spring MVC 框架一般都使用配置文件的方式进行,相对比较繁琐.spring 提供了使用注解方式搭建Spring MVC 框架的方式,方便简洁.使用Spring IOC 作为根容器管 ...
- ubuntu通过apt-get方式搭建lnmp环境以及php扩展安装
v 一直是在用的lnmp的集成安装包搭建lnmp环境,因为工作需要需要安装ldap扩展,在网上怎么都找不到源码安装包,只能卸载掉原来的lnmp环境,用ubuntu的php5-ldap扩展, 在安装中遇 ...
- springMVC_配置文件搭建基础环境
SpringMVC与Struts的区别. 一.基础jar包 二.①DispatcherServlet,handelMapping,webAction(colltroller),ModelAndView ...
- EF6 在原有数据库中使用 CodeFirst 总复习(一、搭建基础环境)
本来以为已经会了,可动手时发现许多问题还是模糊不清,正所谓眼高手低.只能重新查资料,再复习一遍. vs.net2013 ef6 mvc5 sqlserver2008 一.建立数据库 Bloggi ...
- CDH5.2+CM5.2+impala2+Spark1.1 集群搭建基础环境准备
測试集群简单介绍:一共同拥有4台机器:10.10.244.136.10.10.244.137.10.10.244.138.10.10.244.139. 10.10.244.136是管理节点.另外3台是 ...
- (一)OpenStack---M版---双节点搭建---基础环境配置
↓↓↓↓↓↓↓↓视频已上线B站↓↓↓↓↓↓↓↓ >>>>>>传送门 配置如下 本次搭建采用2台4核4G的虚拟机,也可以用2台2核4G 主机名 配置 网络 Contr ...
- django 学习笔记(一)搭建基础环境
1.安装django 下载地址 https://github.com/django/django 解压后进入文件夹运行指令 >> python setup.py install 2.创建工 ...
- ASP.NET MVC4 微信公众号开发之网页授权(一):搭建基础环境
首先你得注册并认证一个个人或企业的微信公众号===服务号从而确保获得以下接口权限: 然后打开公众号设置里的功能设置里找到业务域名和网页授权域名分别填上你的域名(注:已备案的域名),如下图所示: 到这里 ...
随机推荐
- iPhone电话与短信相关代码小结
关于iPhone上电话与短信相关功能,做一个简单总结: 使用公开SDK能实现的功能: (1)获取和操作通讯录.使用函数 ABAddressBookRequestAccessWithCompletion ...
- pycharm中文乱码
python2默认不支持中文,python3支持中文,所以使用python2要注意. 解决方案: 顶部声明一下是utf8编码即可, # encoding=utf8
- Python中@staticmethod和@classmethod的作用和区别
简单介绍一下两者的区别: 对于一般的函数test(x),它跟类和类的实例没有任何关系,直接调用test(x)即可 #!/usr/bin/python # -*- coding:utf-8 -*- de ...
- 【Zookeeper】本地ZK的搭建
很久没有写了..最近看书的笔记都记在有道云上面..框架的使用觉得还是有必要写一下 1.下载 官网:https://www.apache.org/dyn/closer.cgi 清华镜像:https:// ...
- C++——多态性 与 虚函数
多态性 多态性是面向对象程序设计的关键技术之一.若程序设计语言不支持多态性,不能称为面向对象的语言.利用多态性技术,可以调用同一个函数名的函数,实现完全不同的功能. 多态性(polymorphism) ...
- Mybatis.NET Oracle 线上神奇问题:Value does not fall within the expected range.
1.错误现象 在向数据库查询一条数据的时候报如下错误: Value does not fall within the expected range. at Oracle.ManagedDataAcce ...
- IDEA快捷键之关闭标签页和选定单词
下面所说的快捷键仅作为演示使用,个人可根据喜好自行设置 使用Alt + W 选中某个单词 点击IDEA左上角的File 打开Settings 在左侧点击KeyMap 打开右侧的Editor Actio ...
- Luogu P5020 货币系统
Luogu P5020 货币系统 先把$a$数组排一下序. 从最小的数开始选,显然最小这个数必须选,然后利用完全背包的思想,从$a_i$到最大值筛选一遍,将可以组成的打上标记. 在判断后面的数字时,如 ...
- 解密Redis持久化【翻译】
本文来自Redis的作者,他在论坛看到大家对Redis持久化误解较大,所以写此文章论述持久化 写操作的流程 首先我们来看一下数据库在进行写操作时到底做了哪些事,主要有下面五个过程. 客户端向服务端发送 ...
- hihocoder 1931 最短管道距离
描述 在一张2D地图上有N座城市,坐标依次是(X1, Y1), (X2, Y2), ... (XN, YN). 现在H国要修建一条平行于X轴的天然气主管道.这条管道非常长,可以认为是一条平行于X轴的直 ...