本篇文章给大家分享的是有关使用SpringMVC和MyBatis框架如何搭建一个开发环境,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
1,下载SpringMVC框架架包,
点击打开地址如图所示,点击下载即可
& lt;及# 63;xml version=?.0”;编码=癠TF-8", # 63;比;
http://www.w3.org/2001/XMLSchema-instance" & lt; web xmlns: xsi=?;xmlns=癶ttp://xmlns.jcp.org/xml/ns/javaee"xsi: schemaLocation=癶ttp://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"id=癢ebApp_ID"version=?.1“比;
& lt; display-name> CoolWeb
& lt; welcome-file-list>
& lt; welcome-file> index.html
& lt; welcome-file> index.htm
& lt; welcome-file> index.jsp
& lt; welcome-file> default.html
& lt; welcome-file> default.htm
& lt; welcome-file> default.jsp
& lt;/welcome-file-list>
& lt; servlet>
& lt; servlet-name> CoolWeb
& lt; servlet-class> org.springframework.web.servlet.DispatcherServlet
& lt; init-param>
& lt; param-name> contextConfigLocation
& lt; !- & lt; param-value>类路径:application-context.xml——比;
& lt; param-value>类路径:CoolWeb-servlet.xml
& lt;/init-param> & lt; !类,类路径:只会到你的路径中查找找文件;
classpath *:不仅包含类路径,还包括jar文件中(类路径)进行查找。——比;
& lt; load-on-startup> 1 & lt;/load-on-startup>
& lt;/servlet>
& lt; !——如果不配置servlet映射服务器就无法响应/请求——比;
& lt; servlet-mapping>
& lt; servlet-name> CoolWeb
& lt; url-pattern>/& lt;/url-pattern>
& lt;/servlet-mapping>
& lt;/web-app>
7日在src下创建CoolWeb-servlet。xml
& lt;及# 63;xml version=?.0”;编码=癠TF-8", # 63;比; http://www.springframework.org/schema/beans" & lt;豆类xmlns=? xmlns: xsi=癶ttp://www.w3.org/2001/XMLSchema-instance" xmlns:上下文=癶ttp://www.springframework.org/schema/context" xmlns: mvc=癶ttp://www.springframework.org/schema/mvc" xsi: schemaLocation=癶ttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ,http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"的在 & lt; !——开启SpringMVC注解——比; & lt;上下文:component-scan基础包=癱om.vincent.lwx"/比; & lt; mvc:注解驱动/比; & lt;/beans>
8日在src下编写ApplicationContext。xml文件
& lt;及# 63;xml version=?.0”;编码=癠TF-8", # 63;比; http://www.springframework.org/schema/beans" & lt;豆类xmlns=? xmlns: xsi=癶ttp://www.w3.org/2001/XMLSchema-instance" xmlns:上下文=癶ttp://www.springframework.org/schema/context" xmlns: mvc=癶ttp://www.springframework.org/schema/mvc" xsi: schemaLocation=癶ttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ,http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"的在 & lt;上下文:component-scan基础包=癱om.vincent.lwx"/比; & lt; mvc:注解驱动/比; & lt; !——用户实体类——比; & lt; bean id=皍ser"类=癱om.vincent.lwx.bean.User"/比; & lt; !——支持上传文件——比; & lt; bean id=癿ultipartResolver"类=皁rg.springframework.web.multipart.commons.CommonsMultipartResolver"比; & lt;属性名=癲efaultEncoding"值=https://www.yisu.com/zixun/" utf - 8 "/>使用SpringMVC和MyBatis框架如何搭建一个开发环境