6.参数绑定(重点)
Springmvc作为表现层框架,是连接页面和service层的桥梁,它负责所有请求的中转。怎么从请求中接收参数是重点,这也体现了我们刚开始说的Springmvc的第一个作用:“接收请求中的参数”。
接收的参数具体有哪些类型呢?6.1~6.5是绝大部分参数绑定的类型,还有两种第二天课程讲。
6.1.简述参数绑定的类型
1.默认支持的参数类型:HttpServletRequest,HttpServletResponse,HttpSession,Model
2.简单类型:String,long,double,boolean,Integer, Long等
3.POJO类型
4.POJO的包装类型-QueryVo
5.自定义转换器Converter:适合参数在传入方法前做事前加工,比如不能自动完成的类型转换,去空格等。 6.2.需求
前面我们做完了商品列表画面的展示,下面继续做修改页面和保存修改。
【修改页面】:在列表页面点击一条数据的【修改】,根据id查询这条数据的详细信息,然后显示在修改页面
【保存修改】:在修改页面修改信息,然后点【保存】,把信息存到数据库,保存成功迁移到success页面。(正常保存完应该返回列表页面,但我们先做的简单一点,就暂时迁移到success页面。)
下面我们就利用这个修改的业务需求来逐个演示各种参数绑定方法。
6.3.业务实现的代码规划
·默认支持的参数类型实现【修改页面】显示;
·简单类型实现【保存修改】功能;
·POJO类型改进【保存修改】功能;
·针对日期类型,利用自定义转换器Converter实现字符串到日期类型转换,进一步完善【保存修改】功能;
·POJO的包装类型-QueryVo简单说明综合查询业务的综合查询条件的传递。
6.4.默认支持的参数类型
6.4.1.啥是默认支持的参数类型
所谓默认支持的参数类型就是传不传它们都会存在的参数,想用时就在Controller方法中定义即可,用哪个定义哪个,不用不定义。
默认参数有:
HttpServletRequest:通过request对象获取请求信息
HttpServletResponse:通过response处理响应信息
HttpSession:通过session对象得到session中存放的对象
Model:通过Model参数返回需要传递给页面的数据。
注意:如果使用Model参数给页面传值,那方法的返回值可以不使用ModelAndView对象而只返回一个逻辑视图名(String字符串),此时返回的字符串会走视图解析器解析生成View对象。
无论Springmvc怎样对结果和返回值进行处理封装,其本质都是使用Request对象向jsp传递数据。 6.4.2.演示代码
1.【itemList.jsp】的【修改】: 2.【ItemsController.java】新定义一个方法
<说明>
·HttpServletRequest:
可以接收页面传递过来的参数。
·Model:前面讲过,略
/**
* 演示默认支持的类型参数:HttpServletRequest、HttpServletResponse、HttpSession、Model
* 默认支持的参数类型就是传不传它们都存在的参数,想用时就在Controller方法中定义即可,
* 用哪个就定义哪个,不用就不定义。
*/
@RequestMapping("/toEdit")
public String itemEdit(HttpServletRequest request, Model model) throws Exception {
// 取得页面传过来的主键id
Integer id = Integer.valueOf(request.getParameter("id"));
Items itemsResult = itemsService.getItemsDetailById(id);
// 设置返回给页面的数据
model.addAttribute("item", itemsResult);
// 返回页面的逻辑视图名
return "editItem";
}
3.【ItemsService.java】新定义一个接口
public Items findItemsById(Integer id) throws Exception;
4.【ItemsServiceImpl.java】实现上面的接口方法
public Items findItemsById(Integer id) throws Exception {
Items items = itemsMapper.selectByPrimaryKey(id);
return items;
}
5.访问【http://localhost:8080/ssm2/list.action】,点击【修改】
6.将返回页面的数据和返回页面的地址合体返回:
SpringMVC提供一种专门用于Handler返回结果的类:ModelAndView(模型和视图类)。它相当于把Model类和视图路径字符串合并在一起返回。SpringMVC拿到这个类对象后仍然会调度视图解析器来解析这个视图文件路径,并把数据给刚由视图解析器生成的视图对象,由它执行页面的渲染。
改造上面的方法:
/**
* 演示默认支持的类型参数:HttpServletRequest、HttpServletResponse、HttpSession、Model
* 默认支持的参数类型就是传不传它们都存在的参数,想用时就在Controller方法中定义即可,
* 用哪个就定义哪个,不用就不定义。
*/
@RequestMapping("/toEdit")
public ModelAndView itemEdit(HttpServletRequest request, Model model) throws Exception {
// 取得页面传过来的主键id
Integer id = Integer.valueOf(request.getParameter("id"));
Items itemsResult = itemsService.getItemsDetailById(id); ModelAndView modelAndView = new ModelAndView();
// 1. 设置返回页面需要的数据
// 第一个参数是属性名称, 第二个参数是属性值
modelAndView.addObject("item", itemsResult);
// 2. 指定返回页面的地址
modelAndView.setViewName("editItem"); return modelAndView;
}
项目实在中经常使用的还是直接返回字符串的那种,这个返回ModelAndView的不太常用。 6.5.简单类型
默认参数类型有一个缺点:用request.getParameter来取值可能需要额外的类型转换,从String转成其他类型。
Springmvc可不可以直接接收这些类型的参数呢?答案是可以的,即直接接收简单类型的参数。Springmvc不仅可以直接接收多个简单类型参数,还可以自动进行简单的类型转换。
6.5.1.简单类型就是java的简单类型
例如:String、double、long、Integer、Boolean等。
6.5.2.传参规范
页面上input框的name属性值必须等于controller方法中接收时的参数名称
6.5.3.演示代码
1.从【资料\参考案例\jsp】中导入【editItem.jsp】到工程的jsp目录下。
2.【ItemsController.java】新定义一个方法
/**
* 演示接收简单类型:String, Integer, Double, Boolean等
* 要求:页面上input框的name属性值必须等于controller方法中接收时的参数的变量名称
*/
@RequestMapping("/itemUpdate")
public String itemUpdate(Integer id, String name, Float price, String detail)
throws Exception {
Items items = new Items();
items.setId(id);
items.setName(name);
items.setPrice(price);
items.setDetail(detail);
itemsService.updateItems(items);
return "success";
}
3.【ItemsService.java】新定义一个接口
public void updateItems(Items items) throws Exception; 4.【ItemsServiceImpl.java】实现上面的接口方法
public void updateItems(Items items) throws Exception {
itemsMapper.updateByPrimaryKeySelective(items);
}
5.从【资料\参考案例\jsp】中导入【success.jsp】到工程的jsp目录下。
6.进入修改页面修改信息并保存。
6.5.4.解决post提交乱码问题
web页面默认的编码是ISO8859-1,但这个编码不支持汉字,所以汉字参数传递过来会出现乱码。
post请求乱码的解决方法:在web.xml中加一个过滤器解决。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
。。。。
<!-- 配置解决post提交汉字乱码的过滤器 -->
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
。。。。
</web-app> 6.5.5.解决get提交乱码问题
对于get请求中文参数出现乱码解决方法有两个:
1.修改tomcat配置文件【server.xml】添加编码与工程编码一致,如下:(常用) 2.另外一种方法对参数进行重新编码: 6.6.POJO类型
实现对修改保存的改进,适应参数个数的变化,几十上百个参数时候是绝对不可能用简单类型传递参数的。
6.6.1.传参规范
页面中input框的name属性值必须等于Controller方法接收时的POJO参数中的属性名称
6.6.2.演示代码
【ItemsController.java】新定义一个保存更新的方法,将旧的注释掉
/**
* 演示接收简单类型:String, Integer, Double, Boolean等
* 要求:页面上input框的name属性值必须等于controller方法中接收时的参数的变量名称
*/
// @RequestMapping("/itemUpdate")
// public String itemUpdate(Integer id, String name, Float price, String detail)
// throws Exception {
// Items items = new Items();
// items.setId(id);
// items.setName(name);
// items.setPrice(price);
// items.setDetail(detail);
// items.setCreatetime(new Date());
// itemsService.updateItems(items);
// return "success";
// } /**
* 演示接收POJO类型的参数
* 要求:页面上input框的name属性值必须等于pojo中的属性名称
*
* @return
* @throws Exception
*/
@RequestMapping("/itemUpdate")
public String itemUpdate(Items items)
throws Exception {
itemsService.updateItems(items);
return "success"; } 6.7.POJO的包装类型-QueryVo
我们要想在列表页面加一个综合查询功能,查询条件可能有商品信息、用户信息、订单信息,因此我们需要一个QueryVo来包装这些查询信息。那如何传递包装的参数呢?
6.7.1.传参规范
页面中input框的name属性值必须等于Controller方法接收时的Vo参数中的属性.属性.属性....,即各层的属性名要相等。
6.7.2.演示代码
1.新定义【QueryVo.java】
package cn.baidu.pojo; public class QueryVo { // 用户对象
// ......
// 订单对象
// ...... // 商品对象
private Items items; public Items getItems() {
return items;
} public void setItems(Items items) {
this.items = items;
}
}
2.【itemList.jsp】中增加两个查询条件作为POJO的包装类型的示范说明:控件name属性的名称要符合要求。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查询商品列表</title>
</head>
<body>
<form action="${pageContext.request.contextPath }/search.action" method="post">
查询条件:
<table width="100%" border=1>
<tr>
<td>商品名称: <input type="text" name="items.name"></td>
<td>商品价格: <input type="text" name="items.price"></td>
<td><input type="submit" value="查询"/></td>
</tr>
</table>
商品列表:
<table width="100%" border=1>
<tr>
<td>商品名称</td>
<td>商品价格</td>
<td>生产日期</td>
<td>商品描述</td>
<td>操作</td>
</tr>
<c:forEach items="${itemList }" var="item">
<tr>
<td>${item.name }</td>
<td>${item.price }</td>
<td><fmt:formatDate value="${item.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
<td>${item.detail }</td> <td><a href="${pageContext.request.contextPath }/toEdit.action?id=${item.id}">修改</a></td>
</tr>
</c:forEach>
</table>
</form>
</body>
</html>
3.【ItemsController.java】新定义一个方法,这里不做具体的查询过滤,我们主要学习的是参数的传递。
/**
* 演示接收POJO的包装类型 - QueryVo
* 要求: 页面上input框的name属性值必须等于POJO中属性.属性.属性.....
*
* @param vo
* @return
* @throws Exception
*/
@RequestMapping("/search")
public String searchItems(QueryVo vo) throws Exception {
System.out.println(vo);
return "success";
} 6.8.自定义转换器Converter
前台传递的是一个时间格式的字符串,后台数据库存储的是一个日期类型的数据,需要转换,但自动转换会报错(可以试一试)。为了转换需要自定义转换器。
6.8.1.自定义转换器的作用
参数传递到方法之前的统一加工处理。
应用:最多的应用就是复杂类型转换、再有就是去掉金钱中的千分符等。比如:在Springmvc中接收参数时可以自动进行简单类型的类型转换,但是像String转Date这种复杂的类型转换,Springmvc不能自动完成,所以需要手动编写Converter转换器,来进行类型转换。
6.8.2.演示代码
1.将【editItem.jsp】中的【商品生产日期】项目的注释打开
2.自定义转换器Converter
Converter的包名可以随意,我们这里定义一个全局的String到Date的转换器。
都要继承【Converter<S, T>】接口,【S - source源的类型】,【T - target目标的类型】,我们这里的S是String,T是Date。 package cn.baidu.controller.converter; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date; import org.springframework.core.convert.converter.Converter; /**
* S - source源的类型
* T - target目标的类型
* @author Derek Sun
*/
public class CustomGlobalStrToDateConverter implements Converter<String, Date> { public Date convert(String source) {
try {
Date date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(source);
return date;
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
3.Converter的配置方式:
【SpringMVC.xml】
<?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:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<!-- controller层的组件扫描 -->
<context:component-scan base-package="cn.baidu.controller" /> <!-- 配置注解驱动 -->
<!-- 配置加载converter转换器 -->
<mvc:annotation-driven conversion-service="conversionService" /> <!-- 转换器配置 -->
<bean id="conversionService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="converters">
<set>
<bean class="cn.baidu.controller.converter.CustomGlobalStrToDateConverter"/>
</set>
</property>
</bean> <!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="WEB-INF/jsp/" />
<!-- 后缀 -->
<property name="suffix" value=".jsp" />
</bean>
</beans>
4.Converter的配置方式2(了解)
这种方式放到工程里不好用,就是用来理解Converter具体作用在处理器适配器上。
<?xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="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:dubbo="http://code.alibabatech.com/schema/dubbo"xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!-- 扫描带Controller注解的类 -->
<context:component-scanbase-package="cn.baidu.springmvc.controller"/> <!-- 转换器配置 -->
<beanid="conversionService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<propertyname="converters">
<set>
<beanclass="cn.baidu.springmvc.convert.DateConverter"/>
</set>
</property>
</bean>
<!-- 自定义webBinder -->
<beanid="customBinder" class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<propertyname="conversionService"ref="conversionService"/>
</bean>
<!--注解适配器 -->
<beanclass="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<propertyname="webBindingInitializer"ref="customBinder"></property>
</bean>
<!-- 注解处理器映射器 -->
<beanclass="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<!-- 加载注解驱动 -->
<!-- <mvc:annotation-driven/> -->
<!-- 视图解析器 -->
<beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver">
<propertyname="viewClass"
value="org.springframework.web.servlet.view.JstlView"/>
<!-- jsp前缀 -->
<propertyname="prefix"value="/WEB-INF/jsp/"/>
<!-- jsp后缀 -->
<propertyname="suffix"value=".jsp"/>
</bean>
</beans>
注意:此方法需要独立配置处理器映射器、适配器,不再使用<mvc:annotation-driven/> 5. 【ItemsController.java】
/**
* 演示接收POJO类型的参数
* 要求:页面上input框的name属性值必须等于pojo中的属性名称
*/
@RequestMapping("/itemUpdate")
public String itemUpdate(Items items)
throws Exception {
itemsService.updateItems(items);
return "success";
}
再次启动运行。 5.仅仅是做一个日期类型的转化可以不用自定义转换器,还有一种更简单的做法:直接在pojo对应的日期属性变量上面加注解 @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss"),因此SpringMVC.xml恢复原来的配置
【SpringMVC.xml】
<?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:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!-- 配置注解扫描 -->
<context:component-scan base-package="cn.baidu.controller" /> <!-- 企业中配置处理器映射器和处理器适配器:注解驱动 -->
<mvc:annotation-driven /> <!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/jsp/" />
<!-- 后缀 -->
<property name="suffix" value=".jsp" />
</bean>
</beans> 【Items.java】在pojo中对应的日期属性变量上使用注解@DateTimeFormat
public class Items {
。。。。。。
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createtime;
。。。。。。
}
启动测试,这样也是可以进行String到Date的类型转换的。
注意格式:【yyyy-MM-dd HH:mm:ss】
6.9.本节重点
要想顺利的保证前台的数据传到后台,在使用SpringMVC框架的前提下就要遵守SpringMVC传参的规范,具体规范如下:
1.默认支持的参数类型:HttpServletRequest,HttpServletResponse,HttpSession,Model。用哪个就在方法的形参中定义哪个,不用的不定义。
2.简单类型:String,long,double,boolean,Integer等
要求:页面中input框的name属性值必须等于Controller方法接收时的参数名称。
适合单个或少数参数的请求
3.POJO类型
要求:页面中input框的name属性值必须等于Controller方法接收时的POJO参数中的属性名称。
适合更新、插入操作。
4.POJO的包装类型-QueryVo
要求: 页面中input框的name属性值必须等于Controller方法接收时的Vo参数中的属性.属性.属性....
适合综合查询。
5.自定义转换器Converter
作用:参数传递到方法之前的统一加工处理。
应用:复杂类型转换、去空格, 去钱的千分符等 7.Springmvc与Struts2区别
1.入口不同:
springmvc的入口是一个servlet即前端控制器,而struts2入口是一个filter过虑器。
2.请求的拦截级别:
Struts2是类级别的拦截,一个Action类对应一个request上下文;
SpringMVC是方法级别的拦截,一个Controller类的方法对应一个request上下文。
3.单例与多例:
Struts2是基于类开发,传递参数是通过Action类的属性,只能设计为多例。
Springmvc是基于方法开发(一个url对应一个方法),请求参数传递到方法的形参,可以设计为单例或多例(默认是单例)。
4.接收参数和返回数据:
Struts接收的请求参数存放于Action的属性中,是诸多方法共享的,程序可读性差。Struts采用值栈存储请求和响应的数据,通过OGNL存取数据;值栈存储方式太过原始。
Springmvc通过参数解析器是将request请求内容解析并给方法形参赋值,即请求参数是方法之间独立的。Springmvc对数据和视图封装成ModelAndView对象,最后又将ModelAndView中的模型数据通过reques对象传输到页面。 SSM整合思路 :
web系统结构分为:三层
Controller层---> Service层---> Dao层 代码的目录结构:
Controller层
controller目录:用@Controller注解修饰的类——SpringMVC的后端控制器(手动编写)
Service层
service目录:用@Service注解修饰的类——业务处理模型(手动编写)
Dao层
dao目录:mybatis动态代理扫描
利用mybatis逆向工程生成dao接口和映射文件
pojo目录:利用mybatis逆向工程生成pojo 配置文件的目录:
config目录:
SpringMVC的配置文件——SpringMVC.xml
Controller层注解扫描,注解驱动,视图解析器(可能带有前缀和后缀) spring的配置文件
Service层注解扫描,事务管理——ApplicationContext-service.xml
mybatis整合(整合会话工厂、动态代理的包扫描)——ApplicationContext-dao.xml mybatis的配置文件——MybatisConfig.xml
暂时保留一个空的配置文件——保留一个空的配置文件是为了将来好扩展 一些properties属性文件(日志,jdbc) web.xml——是java web的唯一入口
spring的监听
SpringMVC的前端控制器

SpringMVC框架之第二篇的更多相关文章

  1. SpringMVC框架之第一篇

    2.SpringMVC介绍 2.1.SpringMVC是什么 SpringMVC是Spring组织下的一个表现层框架.和Struts2一样.它是Spring框架组织下的一部分.我们可以从Spring的 ...

  2. Lucene&Solr框架之第二篇

    2.1.开发环境准备 2.1.1.数据库jar包 我们这里可以尝试着从数据库中采集数据,因此需要连接数据库,我们一直用MySQL,所以这里需要MySQL的jar包 2.1.2.MyBatis的jar包 ...

  3. Django框架之第二篇--app注册、静态文件配置、form表单提交、pycharm连接数据库、django使用mysql数据库、表字段的增删改查、表数据的增删改查

    本节知识点大致为:静态文件配置.form表单提交数据后端如何获取.request方法.pycharm连接数据库,django使用mysql数据库.表字段的增删改查.表数据的增删改查 一.创建app,创 ...

  4. Java学习笔记——浅谈数据结构与Java集合框架(第二篇、Queue、Set)

    江南好,何处异京华. 香散翠帘多在水,绿残红叶胜于花.无事避风沙. --<纳兰词> 诗词再好,大图不能忘 上大图: 先说说栈和队列: 栈就好比手枪的弹匣,你往里面压入子弹,最先压入的子弹就 ...

  5. Django(三)框架之第二篇

    https://www.cnblogs.com/haiyan123/p/7717788.html 一.知识点回顾 1.MTV模型 model:模型,和数据库相关的 template:模板,存放html ...

  6. Django框架之第二篇

    一.知识点回顾 1.MTV模型 model:模型,和数据库相关的 template:模板,存放html文件,模板语法(目的是将变量如何巧妙的嵌入到HTML页面中). views:视图函数 另加urls ...

  7. 开源DDD设计模式框架YMNNetCoreFrameWork第二篇-增加swagger,数据库迁移,增加权限模型

    1.框架去掉application层,把HOst作为application层 2.增加swagger插件 3.增加Asp.net  Identity身份验证 源代码地址:https://github. ...

  8. ASP.NET WebAPI框架解析第二篇(HttpModule的创建和使用)

    我们先看一下执行流程图 图中画红圈的部分便是HttpModule,在说创建HttpModule之前,先说一下HttpApplication对象,HttpApplication对象由Asp.net框架创 ...

  9. MyBatis框架之第二篇

    1.高级参数映射和返回值映射(重点) a)Pojo包装pojo的参数映射 b)当结果集列名与pojo属性名不一致的返回值映射 2.动态sql(重点) 3.关联查询结果(重点) a)一对一关联结果 b) ...

随机推荐

  1. 【nodejs原理&源码赏析(9)】用node-ssh实现轻量级自动化部署

    [摘要] node脚本实现轻量级自动化部署 示例代码托管在:http://www.github.com/dashnowords/blogs 一. 需求描述 前端工程出包后实现简易的自动化部署. 二. ...

  2. window安装jboss服务器

    window安装jboss服务器 1.下载jboss服务器 地址:http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as ...

  3. qs库使用指南

    qs是一个流行的查询参数序列化和解析库.可以将一个普通的object序列化成一个查询字符串,或者反过来将一个查询字符串解析成一个object,而且支持复杂的嵌套.它上手很容易: Qs.parse('x ...

  4. luogu P3913 车的攻击 |数学

    题目描述 N×N 的国际象棋棋盘上有KK 个车,第ii个车位于第R_i行,第C_i列.求至少被一个车攻击的格子数量. 车可以攻击所有同一行或者同一列的地方. 输入格式 第1 行,2 个整数N,K. 接 ...

  5. 小白学 Python 爬虫(17):Requests 基础使用

    人生苦短,我用 Python 前文传送门: 小白学 Python 爬虫(1):开篇 小白学 Python 爬虫(2):前置准备(一)基本类库的安装 小白学 Python 爬虫(3):前置准备(二)Li ...

  6. ES6——async函数

    目录 1.async 函数是 Generator 函数的语法糖. 2.async函数对 Generator 函数的改进,体现在以下四点. 3.基本用法 一个获取股票报价的函数 指定多少毫秒后输出一个值 ...

  7. MYSQL“错误代码#1045 Access denied for user 'root'@'********8' (using password:YES)”

    用IP远程连接数据库时报这个错误,我查看了下数据库是否开启了远程连接,已经开了,服务也启动着,网上的方法都是重置密码修改权限之类的,我发现都没用,我看了一下数据库所在的电脑,IP地址变了,然后真相了.

  8. HDU-3339 IN ACTION(Dijkstra +01背包)

      Since 1945, when the first nuclear bomb was exploded by the Manhattan Project team in the US, the ...

  9. 初次在Vue项目使用TypeScript,需要做什么

    前言 总所周知,Vue新版本3.0 使用 TypeScript 开发,让本来就很火的 TypeScript 受到更多人的关注.虽然 TypeScript 在近几年才火,但其实它诞生于2012年10月, ...

  10. 小程序如何支持使用 async/await

    下载 regenerator-runtime npm i regenerator-runtime 如何使用 在小程序中,不认识 node_modules 文件夹,无法通过以下方法来直接找到包文件 im ...