SSH(二)
SSH框架整合的系统架构,Action、Service、Dao、SessionFactory、DataSource都可以作为Spring的Bean组件管理
使用HibernateDaoSupport基类(二):
1.实现步骤:
1).DAO类继承HibernateDaoSupport
2).使用getHibernateTemplate()方法获取HibernateTemplate实例完成持久化操作
简化Hibernate DAO的编码
2.将SessionFactory注入DAO -- HibernateDaoSupport基类的setSessionFactory()方法
范例:
<bean id="userDao" class="com.xuetang9.demo.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
3.创建HibernateTemplate实例
添加业务层和事务机制:
1.控制事务
a.可以采用Hibernate控制事务
b.事务应该在业务逻辑层控制
c.硬编码方式,代码繁琐,且破坏分层,代码不易维护
所以:
1.可以采用AOP的方式实现
2.Spring提供了声明式事务支持
2.配置声明式事务
1)核心问题:对不同的方法,采取不同的事务策略
2)步骤:
a.导入tx和aop命名空间
b.配置事务管理器,并为其注入SessionFactory
c.基于该事务管理器配置事务增强,指定事务规则
d.定义切入点
f.织入事务切面
范例:
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:advice id="tx" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="search*" propagation="REQUIRED" read-only="true"/>
<tx:method name="modify*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice> <aop:config>
<aop:pointcut expression="execution(* com.xuetang9.demo.service..*.*(..) )" id="txpoint"/>
<aop:advisor advice-ref="tx" pointcut-ref="txpoint"/>
</aop:config>
3)事务属性
1.tx:method
a.propagation:事务传播机制
REQUIRED(默认值)
SUPPORTS
b.isolation:事务隔离等级
DEFAULT(默认值)
READ_COMMITTED
c.timeout:事务超时时间。
允许事务运行的最长时间,以秒为单位。默认值为-1,表示不超时
d.read-only:事务是否为只读。
默认值为false
e.rollback-for:设定能够触发回滚的异常类型
Spring默认只在抛出runtime exception时才标识事务回滚
可以通过全限定类名指定需要回滚事务的异常,多个类名用逗号隔开
f.no-rollback-for:设定不触发回滚的异常类型
Spring默认checked Exception不会触发事务回滚
可以通过全限定类名指定不需回滚事务的异常,多个类名用英文逗号隔开
Spring与Struts2集成:
1.实现步骤:
1)添加struts2-spring-plugin-xxx.jar
2)按照名称匹配的原则定义业务Bean和Action中的setter方法
3)在struts.xml正常配置Action
2.模板与回调机制
Spring提供回调机制:
a.模板固化了不变的、流程化的内容,简化使用
b.回调允许我们在固化的流程中加入变化的内容
c.HibernateCallback接口
public Object execute(HibernateCallback action) throws DataAccessException
public List executeFind(HibernateCallback action) throws DataAccessException
范例:
public List<Employee> find(final int page, final int size) {
return getHibernateTemplate().executeFind(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createQuery("from Employee");
query.setFirstResult((page - 1) * size);
query.setMaxResults(size);
return query.list();
}
}
);
}
Q:当把方法中的局部变量传递给它的内部类使用时,必须把该变量声明为final,但该方法已过时
A:推荐使用 findByCriteria(DetachedCriteria criteria)/findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults)
3.Struts 2和Spring手动集成 -- 灵活配置Action(Spring配置文件中声明)
1).范例:
< !-- 在Spring配置文件中配置Action Bean,注意scope="prototype"属性 -->
<bean id="userAction" class="com.xuetang9.demo.action.UserAction" scope="prototype">
< !-- 省略其他配置 -->
</bean> < !-- 在Struts.xml中配置Action -->
<package name="login" extends="struts-default">
<action name="login" class="userAction" method="login">
< !-- 省略其他配置 -->
</action>
</package>
【注意:class属性的值不再是Action类的全限定名,而是Spring配置文件中相应的Action Bean的名称】
2).使用注意:
1. 采用此种配置方式时,Action的实例由Spring创建,Struts 2插件的工厂类只需根据Action Bean的id查找该组件使用即可
2. 此种方式可以为Action进行更灵活的配置,但代价是在Spring配置文件中需要定义很多Action Bean,增加了配置工作量,如非必需并非首选
3. 采用此种配置方式,同样需要添加struts2-spring-plugin-xxx.jar文件
4.Spring中Bean的作用域
作用域 说 明
singleton 默认值。Spring以单例模式创建Bean的实例,即容器中该Bean的实例只有一个
prototype 每次从容器中获取Bean时,都会创建一个新的实例
request 用于Web应用环境,针对每次HTTP请求都会创建一个实例
session 用于Web应用环境,同一个会话共享同一个实例,不同的会话使用不同的实例
global session 仅在Portlet的Web应用中使用,同一个全局会话共享一个实例。对于非Portlet环境,等同于session
注意:使用Web环境下的作用域,要在web.xml文件中配置 -- RequestContextListener或RequestContextFilter
范例:
1.实体类及其配置文件
a.User类
package com.Elastic.SpringDemo3.ivy.entity; import java.io.Serializable; public class User implements Serializable {
private String userName;
private String passWord; public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
}
b.User.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2016-7-6 9:25:44 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="com.Elastic.SpringDemo3.ivy.entity.User" table="user">
<id name="userName" type="java.lang.String">
<column name="userName" />
<generator class="assigned" />
</id>
<property name="passWord" type="java.lang.String">
<column name="passWord" />
</property>
</class>
</hibernate-mapping>
2.dao包
a.UserDao接口
package com.Elastic.SpringDemo3.ivy.dao; import java.io.Serializable;
import java.util.List; import com.Elastic.SpringDemo3.ivy.entity.User; public interface UserDao {
void save(User user); void delete(User user); void update(User user); User findById(Serializable id); List<User> find();
}
3.dao.imp包
a.UserDaoImpl
package com.Elastic.SpringDemo3.ivy.dao.impl; import java.io.Serializable;
import java.util.List; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import com.Elastic.SpringDemo3.ivy.dao.UserDao;
import com.Elastic.SpringDemo3.ivy.entity.User; public class UserDaoImpl extends HibernateDaoSupport implements UserDao { @Override
public void save(User user) {
this.getHibernateTemplate().save(user); } @Override
public void update(User user) {
this.getHibernateTemplate().update(user); } @Override
public User findById(Serializable id) {
return this.getHibernateTemplate().get(User.class, id); } @Override
public List<User> find() {
return this.getHibernateTemplate().find("from User ");
} @Override
public void delete(User user) {
this.getHibernateTemplate().delete(user); }
}
4.service包
a.UserService
package com.Elastic.SpringDemo3.ivy.service; import com.Elastic.SpringDemo3.ivy.entity.User; public interface UserService {
User login(String name, String pass);
}
5.service.impl包
a.UserServiceImpl
package com.Elastic.SpringDemo3.ivy.service.impl; import com.Elastic.SpringDemo3.ivy.dao.UserDao;
import com.Elastic.SpringDemo3.ivy.entity.User;
import com.Elastic.SpringDemo3.ivy.service.UserService; public class UserServiceImpl implements UserService { private UserDao userDao; public UserDao getUserDao() {
return userDao;
} public void setUserDao(UserDao userDao) {
this.userDao = userDao;
} @Override
public User login(String name, String pass) {
User user = userDao.findById(name);
if (null != user && user.getPassWord().equals(pass)) {
return user;
}
return null;
}
}
6.action包
a.UserAction
package com.Elastic.SpringDemo3.ivy.action; import com.Elastic.SpringDemo3.ivy.entity.User;
import com.Elastic.SpringDemo3.ivy.service.UserService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport {
private UserService userService;
private User user; public User getUser() {
return user;
} public void setUser(User user) {
this.user = user;
} public UserService getUserService() {
return userService;
} public void setUserService(UserService userService) {
this.userService = userService;
} public String login() {
System.out.println(this);
User login = userService.login(user.getUserName(), user.getPassWord()); if (null == login) {
return ERROR;
}
return SUCCESS;
}
}
7.Spring配置文件
a1. Struts 2和Spring集成 -- applicationContext.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: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/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"> <!-- 使用Spring集成Hibernate(方法2:不需要hibernate配置文件) -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="root"></property>
<property name="password" value="root"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost/hibernatedb"></property>
<property name="driverClass" value="com.mysql.jdbc.Driver"></property> <!-- 连接池 -->
<property name="initialPoolSize" value="10"></property>
<property name="minPoolSize" value="5"></property>
<property name="maxPoolSize" value="100"></property>
<property name="acquireIncrement" value="3"></property>
<!-- 请求获取连接的重试次数 -->
<property name="acquireRetryAttempts" value="3"></property>
<property name="acquireRetryDelay" value="5"></property>
<property name="idleConnectionTestPeriod" value="60"></property>
</bean> <!-- 使用dataSource配置SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="show_sql">true</prop>
<prop key="format_sql">true</prop>
</props>
</property>
<!-- 通配 -->
<property name="mappingLocations" value="classpath:com/Elastic/SpringDemo3/ivy/entity/*.hbm.xml"><!-- 注意classpath的拼写 -->
</property>
</bean> <!-- 配置事务 -->
<!-- 配置事务管理器(增强的功能/切面) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 事务级别(真正的增强功能) -->
<tx:advice id="tx" transaction-manager="transactionManager">
<tx:attributes>
<!-- 方法细分 -->
<!-- [propagation(事务级别)]REQUIRED(默认): 如果前面已经开启事务,把这个事务合并到上一个事务中 ,并把当前方法放进合并后的事务中 -->
<!-- read-only(只读):查询。防止脏数据。 -->
<tx:method name="login" propagation="REQUIRED" read-only="true" timeout="3"/>
<!-- 通配 -->
<tx:method name="search*" propagation="REQUIRED" read-only="true" timeout="10"/>
<tx:method name="modify*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
</tx:attributes>
</tx:advice>
<!-- 配置哪些方法需要使用事务 -->
<aop:config>
<aop:pointcut expression="execution(* com.Elastic.SpringDemo3.ivy.service..*.*(..))" id="txpointcut"/>
<aop:advisor advice-ref="tx" pointcut-ref="txpointcut"/>
</aop:config> <!-- 配置Dao -->
<bean id="userDao" class="com.Elastic.SpringDemo3.ivy.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> <!-- 配置Service -->
<bean id="userService" class="com.Elastic.SpringDemo3.ivy.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean> </beans>
a2. Struts 2和Spring手动集成:Action声明在Spring的配置文件 -- applicationContext.xml
注意:这里的Action是单例模式,Action声明中必须要有scope属性
<?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: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/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"> <!-- 使用Spring集成Hibernate(方法2:不需要hibernate配置文件) -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="root"></property>
<property name="password" value="root"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost/hibernatedb"></property>
<property name="driverClass" value="com.mysql.jdbc.Driver"></property> <!-- 连接池 -->
<property name="initialPoolSize" value="10"></property>
<property name="minPoolSize" value="5"></property>
<property name="maxPoolSize" value="100"></property>
<property name="acquireIncrement" value="3"></property>
<!-- 请求获取连接的重试次数 -->
<property name="acquireRetryAttempts" value="3"></property>
<property name="acquireRetryDelay" value="5"></property>
<property name="idleConnectionTestPeriod" value="60"></property>
</bean> <!-- 使用dataSource配置SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="show_sql">true</prop>
<prop key="format_sql">true</prop>
</props>
</property>
<!-- 通配 -->
<property name="mappingLocations" value="classpath:com/Elastic/SpringDemo3/ivy/entity/*.hbm.xml"><!-- 注意classpath的拼写 -->
</property>
</bean> <!-- 配置事务 -->
<!-- 配置事务管理器(增强的功能/切面) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 事务级别(真正的增强功能) -->
<tx:advice id="tx" transaction-manager="transactionManager">
<tx:attributes>
<!-- 方法细分 -->
<!-- [propagation(事务级别)]REQUIRED(默认): 如果前面已经开启事务,把这个事务合并到上一个事务中 ,并把当前方法放进合并后的事务中 -->
<!-- read-only(只读):查询。防止脏数据。 -->
<tx:method name="login" propagation="REQUIRED" read-only="true" timeout="3"/>
<!-- 通配 -->
<tx:method name="search*" propagation="REQUIRED" read-only="true" timeout="10"/>
<tx:method name="modify*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
</tx:attributes>
</tx:advice>
<!-- 配置哪些方法需要使用事务 -->
<aop:config>
<aop:pointcut expression="execution(* com.Elastic.SpringDemo3.ivy.service..*.*(..))" id="txpointcut"/>
<aop:advisor advice-ref="tx" pointcut-ref="txpointcut"/>
</aop:config> <!-- 配置Dao -->
<bean id="userDao" class="com.Elastic.SpringDemo3.ivy.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> <!-- 配置Service -->
<bean id="userService" class="com.Elastic.SpringDemo3.ivy.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean> <!-- 配置Action -->
<bean id="userAction" class="com.Elastic.SpringDemo3.ivy.action.UserAction" scope="prototype">
<property name="userService" ref="userService"></property>
</bean>
</beans>
8.Struts配置文件
a1. Struts 2和Spring集成 -- struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"> <struts>
<package name="default" namespace="/" extends="struts-default">
<action name="login" class="com.Elastic.SpringDemo3.ivy.action.UserAction" method="login">
<result name="success">/index.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package> </struts>
a2. Struts 2和Spring手动集成 -- struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"> <struts>
<package name="default" namespace="/" extends="struts-default">
<!-- class属性不再是全限定名,而是Spring配置文件中的Action声明的id -->
<action name="login" class="userAction" method="login">
<result name="success">/index.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package> </struts>
9.jsp
a.login.jsp
<%-- 引入JSP页面PAGE指令 --%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%-- 引入JSTL标签指令 --%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html>
<html language="zh-CN">
<head>
<meta charset="utf-8">
<!-- 设置浏览器渲染的引擎 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- 设置支持移动设备 -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>网页标题</title>
<!-- 引用bootstrap样式 -->
<link rel="stylesheet" type="text/css"
href="<%=request.getContextPath()%>/css/bootstrap.min.css">
</head>
<body>
<s:debug></s:debug>
<div class="container-fluid">
<div class="panel panel-default center-block" style="width: 500px;">
<div class="panel-heading">登录</div>
<div class="panel-body">
<form action="login" method="post" class="form-horizontal">
<div class="form-group">
<label class="col-md-3 control-label" for="userName">用户名:</label>
<div class="col-md-6">
<input class="form-control" id="userName" name="user.userName"
type="text" autocomplete="off" />
</div>
<div class="col-md-3"></div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="passWord">密码:</label>
<div class="col-md-6">
<input class="form-control" id="passWord" name="user.passWord"
type="password" />
</div>
<div class="col-md-3"></div>
</div>
<div class="form-group">
<div class="col-md-offset-3 col-md-6">
<input class="btn btn-primary btn-block" type="submit" value="登录" />
</div>
</div>
</form>
</div>
</div>
</div> <!-- 引用外部JS文件 -->
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/jquery-2.2.4.js"></script>
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/bootstrap.min.js"></script> </body>
</html>
10.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">
<display-name>SpringDemo3_ivy</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> <!-- 配置Spring文件的位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param> <!-- 配置的是Spring的启动监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- 配置OpenSessionInView模式 -->
<filter>
<filter-name>OpenSessionInView</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInView</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 配置Struts2 核心过滤器 -->
<filter>
<filter-name>Struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 配置HttpSession过期时间(单位:分钟) -->
<session-config>
<session-timeout>20</session-timeout>
</session-config>
</web-app>
SSH(二)的更多相关文章
- Mac 使用SSH远程登录
一.打开ssh Mac Terminal是自带SSH的,可以用whereis来看看: $ whereis ssh 但是在现有进程中找不到ssh对应的进程: $ ps aux | grep ssh ap ...
- Gitee(码云)、Github同时配置ssh key
一.cd ~/.ssh 二.通过下面的命令,依次生成两个平台的key $ ssh-keygen -t rsa -C "xxxxxxx@qq.com" -f "github ...
- 【工具大道】使用SSH远程登录Mac 电脑
本文地址 一.打开ssh Mac Terminal是自带SSH的,可以用whereis来看看: $ whereis ssh 但是在现有进程中找不到ssh对应的进程: $ ps aux | grep s ...
- 如何生成git ssh key
公司有自己的git版本控制,自己注册账号后,管理员同意,就可以查看项目代码了,但是要克隆的话需要在本地生成git ssh key 一.进入.ssh文件夹. cd ~/.ssh 若没有.ssh文件夹,则 ...
- 网络编程基础【day09】:实现简单地ssh(四)
本节内容 概述 简单ssh socket接收大数据的困惑 一.概述 我们用过linux的就知道什么是ssh,它是一种客户端和服务端交互返回的一个解决,输入一个命令,给我返回什么,接下来我们说一说,如何 ...
- windows下配置ssh访问github
一.说明 一直使用HTTPS的方式访问github的代码,用的时间长了,发现这是效率很低的一种开发行为,因为每次git push的时候都要输入username和password.今天就介绍如何在win ...
- SSH Secure Shell Client--- the host may be dow
the host may be down,or there may be a problem with the network connection. Sometimes such problems ...
- Kali 远程登陆SSH
一.配置SSH 编辑/etc/ssh/sshd_config 将#PasswordAuthentication no的注释去掉,将NO修改为YES //可以用密码登陆 将PermitRootLogin ...
- Linux下安装并配置SSH服务
一.使用命令检测Linux系统上是否已经安装了SSH服务:(命令:rpm -qa |grep ssh) 二.如果没有安装SSH软件包,可以通过yum 或rpm安装包进行安装(命令:yum instal ...
随机推荐
- (二)unittst用例操作
一.跳过用例 @unittest.skip(reason) 跳过被此装饰器装饰的测试. reason 为测试被跳过的原因. 应用场景: 1,有些用例不需要再次执行,或者作废的用例 2,本次测试构建,不 ...
- 简单聊一聊JS中的循环引用及问题
本文主要从 JS 中为什么会出现循环引用,垃圾回收策略中引用计数为什么有很大的问题,以及循环引用时的对象在使用 JSON.stringify 时为什么会报错,怎样解决这个问题简单谈谈自己的一些理解. ...
- php部署后错误排查流程
未使用框架的php程序不可用时,没有框架提供的调试信息,因此要按照请求的整个生命周期来调试程序, 具体错误依次排查网络,服务器,环境,代码的步骤层层深入,最终定位到错误的发生点. 1 访问程序部署的服 ...
- 《Java核心技术》 JVM指令集
https://www.jianshu.com/p/bc91c6b46d7b
- mysql的查询优化
参考网站:http://www.liyblog.top/p/6 这里总结了52条对sql的查询优化,下面详细来看看,希望能帮助到你 1, 对查询进行优化,应尽量避免全表扫描,首先应考虑在 wh ...
- python爬虫——selenium+chrome使用代理
先看下本文中的知识点: python selenium库安装 chrome webdirver的下载安装 selenium+chrome使用代理 进阶学习 搭建开发环境: selenium库 chro ...
- JS绘图
https://www.highcharts.com.cn/demo/highcharts/ 百度的Echarts https://www.echartsjs.com/zh/index.html
- 从0开发3D引擎(七):学习Reason语言
目录 上一篇博文 介绍Reason Reason的优势 如何学习Reason? 介绍Reason的部分知识点 大家好,本文介绍Reason语言以及学习Reason的方法. 上一篇博文 从0开发3D引擎 ...
- MyBatis4——一对一、一对多关联查询
关联查询: 一对一: 1.业务扩展类 核心:用resultType指定的类的属性包含多表查询的所有字段. 2.resultMap 通过添加属性成员建立两个类之间的连接 <!--利 ...
- (转)调皮的location.href
来自 wooyun'drops --->呆子不开口 0x00 背景 随着水瓶月的到来,在祖国繁荣昌盛的今天,web系统的浏览器端也越来越重,很多的功能逻辑都放在了js中,前端的漏洞也越来越多. ...