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 微信公众号开发之网页授权(一):搭建基础环境
首先你得注册并认证一个个人或企业的微信公众号===服务号从而确保获得以下接口权限: 然后打开公众号设置里的功能设置里找到业务域名和网页授权域名分别填上你的域名(注:已备案的域名),如下图所示: 到这里 ...
随机推荐
- 可以在一个.java文件中写两个类吗?
一个java文件中可以有任意多个类,接口或是注解..但是只能有一个类是public的,而且这个类的名字要和文件同名,比如public类名为A则文件名就应当为A.java
- 【转】Java基础——面试题汇总
1.JDK 和 JRE 有什么区别? JDK:Java Development Kit 的简称,java 开发工具包,提供了 java 的开发环境和运行环境. JRE:Java Runtime Env ...
- Topics in CS(difference between compile and interpret)
编译 Compile:把整个程序源代码翻译成另外一种代码,然后等待被执行,发生在运行之前,产物是「另一份代码」. 解释 Interpret:把程序源代码一行一行的读懂然后执行,发生在运行时,产物是「运 ...
- MySQL binlog反解析
反解析delete语句 背景:delete table忘了加条件导致整张表被删除 恢复方式:直接从binlog里反解析delete语句为insert进行恢复 导出删指定表的DELETE语句: # my ...
- 从零开始搭建vue移动端项目到上线
先来看一波效果图 初始化项目 1.在安装了node.js的前提下,使用以下命令 npm install --g vue-cli 2.在将要构建项目的目录下 vue init webpack mypro ...
- [LeetCode] 121. 买卖股票的最佳时机 ☆(动态规划)
https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/solution/xiang-xi-tong-su-de-si-lu- ...
- git的下载和安装
Git 安装配置 在使用Git前我们需要先安装 Git.Git 目前支持 Linux/Unix.Solaris.Mac和 Windows 平台上运行. Git 各平台安装包下载地址为:http://g ...
- TLS1.3 认证和秘钥建立握手环节的分析
1.ClientHello 中的参数 ClientHello---{ Random_C .extension } 在 extension中的扩展中包含 ( supported_version ...
- 理解serverless无服务
理解serverless无服务 阅读目录 一:什么是serverless无服务? 二:与传统模式架构区别? 三:serverless优缺点? 四:使用serverless的应用场景有哪些? 回到顶部 ...
- mysql查询某一列的数据最大字节
语法:select 列名, length(列名) from 表名where length(列名) = ( select max(length(列名)) from 表名); 实例:select proj ...