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 ...
随机推荐
- 【题解】Leyni,罗莉和队列(树状数组)
[题解]Leyni,罗莉和队列(树状数组) HRBUST - 1356 将整个序列reverse一下,现在就变成了从高到低的排队.题目就变成了,定位一个妹子,问这个妹子前面的比这个妹子小的妹子中,下标 ...
- JVM探秘:Java内存区域
本系列笔记主要基于<深入理解Java虚拟机:JVM高级特性与最佳实践 第2版>,是这本书的读书笔记. 概述 Java 虚拟机为程序员分担了很多内存管理的工作,不再像 C/C++ 那样容易出 ...
- 洛谷P1189 SEARCH 题解 迭代加深
题目链接:https://www.luogu.com.cn/problem/P1189 题目大意: 给你一个 \(n \times m\) 的矩阵,其中有一些格子可以走,一些各自不能走,然后有一个点是 ...
- 洛谷P1002 过河卒 题解 动态规划
题目链接:https://www.luogu.com.cn/problem/P1002 题目大意 棋盘上\(A\)点有一个过河卒,需要走到目标\(B\)点.卒行走的规则:可以向下.或者向右.同时在棋盘 ...
- 使用Theia——添加语言支持
上一篇:使用Theia——创建插件 Theia——添加语言支持 Theia中TextMate的支持 使用TextMate语法可以为大部分源文件提供精准的着色修饰,虽然这只是在语法级别上(没有语言本身的 ...
- array_diff 大bug
$aa = array("手机号", "first","keyword1","keyword2","keywo ...
- bootstrap:导航下拉菜单
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name ...
- 小白学Java:包装类
目录 小白学Java:包装类 包装类的继承关系 创建包装类实例 自动装箱与拆箱 自动装箱 自动拆箱 包装类型的比较 "=="比较 equals比较 自动装箱与拆箱引发的弊端 自动装 ...
- Java操作Jxl实现数据交互。三部曲——《第一篇》
Java操作Jxl实现.xsl及.xsls两种数据表格进行批量导入数据到SQL server数据库. 本文实现背景Web项目:前台用的框架是Easyui+Bootstrap结合使用,需要引入相应的Js ...
- spark和strom优劣分析
对于Storm来说:1.建议在那种需要纯实时,不能忍受1秒以上延迟的场景下使用,比如实时金融系统,要求纯实时进行金融交易和分析2.此外,如果对于实时计算的功能中,要求可靠的事务机制和可靠性机制,即数据 ...