JDBC的使用步骤
首先给出 MySql JDBC官方文档
步骤如下:
1加载数据库驱动,这个驱动由数据库厂商提供
2建立连接,获取Connection
3通过Statement对象访问数据库,由Connection产生,执行SQL语句
4如果需要返回值,创建ResultSet对象,保存Statement执行之后查询的结果
5释放资源
<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"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
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
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd ">
<context:component-scan base-package="com.yun.controller"/>
<!-- 开启注解支持 -->
<!-- spring 可以自动去扫描 base-package下面的包或子包下面的Java文件,
如果扫描到有Spring的相关注解的类,则把这些类注册为Spring的bean -->
<mvc:annotation-driven></mvc:annotation-driven>
<!--设置配置方案 -->
<!-- 解决了@Controller注解的使用前提配置<context:annotation-config/>是对包进行扫描,实现注释驱动Bean定义,同时将bean自动注入容器中使用。即解决了@Controller标识的类的bean的注入和使用。 -->
<!-- 会自动注册RequestMappingHandlerMapping与RequestMappingHandlerAdapter两个Bean,
(对action写JUnit单元测试时,要从spring IOC容器中取两个bean,来完成测试)
这是Spring MVC为@Controller分发请求所必需的,并且提供了数据绑定支持,
@NumberFormatannotation支持,
@DateTimeFormat支持,
@Valid支持读写XML的支持(JAXB)
和读写JSON的支持(默认Jackson)等功能。(我们处理响应ajax请求时,就使用到了对json的支持。)-->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.yun.interceptor.LoignInterceptor"></bean>
</mvc:interceptor>
</mvc:interceptors>
<!--@RequestMapping()匹配类加方法
"/*" 直接对应路径可被拦截
"/**" 所有拦截
"/you/*" 对应
"/" 都不能被拦截-->
public class LoignInterceptor implements HandlerInterceptor {
(99条消息) springmvc interceptor拦截器 <mvc:mapping path="/**" />_youz1976的博客-CSDN博客_mvc:mapping
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize">
<value>509715200</value>
</property>
</bean>
<!--配置文件上传使用解析器--><!-- 指定上传文件最大尺寸 -->
<!-- 通用的多路上传解析器
Spring MVC支持一个通用的多路上传解析器CommonsMultipartResolver,
在Spring的配置文件中对CommonsMultipartResolver Bean进行配置时,
有一些可选的属性配置。-->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/><!-- 该目录下 -->
<property name="suffix" value=".jsp"/><!-- 后缀 -->
</bean>
</beans>
<!-- springmvc的视图解析器:Controller返回的时候进行解析视图 -->
通常是用来配置jsp的
html和jsp
(99条消息) springmvc的InternalResourceViewResolver自我理解_wwzuizz的博客-CSDN博客_internalresourceviewresolver