• 背景:

  基于之前两篇文章《Spring(三):Spring整合Hibernate》、《Spring(四):Spring整合Hibernate,之后整合Struts2》,了解了如何整合SSH的过程,但还不知道整合后在项目中该怎么开发使用,本文主要讲解的是基于SSH实现Employee信息查询功能的使用。

  • 新建Employee,Department实体类,并添加对应类的hibernate实体配置文件

  新建包com.dx.ssh.entities,在该包下创建Employee、Department实体类,并添加对应的hibernate实体配置文件Employee.hbm.xml、Department.hbm.xml

Employee.java

 package com.dx.ssh.entities;

 public class Department {
private Integer id;
private String deparmentName; public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getDeparmentName() {
return deparmentName;
} public void setDeparmentName(String deparmentName) {
this.deparmentName = deparmentName;
}
}

Employee.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 2017-5-9 16:33:32 by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
<class name="com.dx.ssh.entities.Department" table="SSH_DEPARTMENT">
<id name="id" type="java.lang.Integer">
<column name="ID" />
<generator class="native" />
</id>
<property name="deparmentName" type="java.lang.String">
<column name="DEPARMENTNAME" />
</property>
</class>
</hibernate-mapping>

Department.java

 package com.dx.ssh.entities;

 import java.util.Date;

 public class Employee {
private Integer id;
private String lastName;
private String email;
private Date birth;
// 不能被修改
private Date createTime;
// n:1的关系
private Department department; public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getLastName() {
return lastName;
} public void setLastName(String lastName) {
this.lastName = lastName;
} public String getEmail() {
return email;
} public void setEmail(String email) {
this.email = email;
} public Date getBirth() {
return birth;
} public void setBirth(Date birth) {
this.birth = birth;
} public Date getCreateTime() {
return createTime;
} public void setCreateTime(Date createTime) {
this.createTime = createTime;
} public Department getDepartment() {
return department;
} public void setDepartment(Department department) {
this.department = department;
}
}

Department.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 2017-5-9 16:33:32 by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
<class name="com.dx.ssh.entities.Employee" table="SSH_EMPLOYEE">
<id name="id" type="java.lang.Integer">
<column name="ID" />
<generator class="native" />
</id>
<property name="lastName" type="java.lang.String">
<column name="LASTNAME" />
</property>
<property name="email" type="java.lang.String">
<column name="EMAIL" />
</property>
<property name="birth" type="java.util.Date">
<column name="BIRTH" />
</property>
<property name="createTime" type="java.util.Date">
<column name="CREATETIME" />
</property>
<!-- 单项N:1关联关系 -->
<many-to-one name="department" class="com.dx.ssh.entities.Department">
<column name="DEPARTMENT_ID" />
</many-to-one>
</class>
</hibernate-mapping>
  • 添加Dao、Service、Action,并配置相关配置文件

添加包com.dx.ssh.dao,并新建EmployeeDao.java

package com.dx.ssh.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory; import com.dx.ssh.entities.Employee; public class EmployeeDao {
private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
} private Session getSession() {
return this.sessionFactory.getCurrentSession();
} public List<Employee> getAll() {
String hql = "From Employee e LEFT OUTER JOIN FETCH e.department";
return getSession().createQuery(hql).list();
}
}

在com.dx.ssh.service包下,新建EmployeeService.java

package com.dx.ssh.service;

import java.util.List;

import com.dx.ssh.dao.EmployeeDao;
import com.dx.ssh.entities.Employee; public class EmployeeService {
private EmployeeDao employeeDao; public void setEmployeeDao(EmployeeDao employeeDao) {
this.employeeDao = employeeDao;
} public List<Employee> getAll() {
List<Employee> items = employeeDao.getAll(); return items;
}
}

在com.dx.ssh.actions下,新建Action类EmployeeAction.java

package com.dx.ssh.service;

import java.util.List;

import com.dx.ssh.dao.EmployeeDao;
import com.dx.ssh.entities.Employee; public class EmployeeService {
private EmployeeDao employeeDao; public void setEmployeeDao(EmployeeDao employeeDao) {
this.employeeDao = employeeDao;
} public List<Employee> getAll() {
List<Employee> items = employeeDao.getAll(); return items;
}
}

配置applicationContext-beans.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="employeeDao" class="com.dx.ssh.dao.EmployeeDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> <bean id="employeeService" class="com.dx.ssh.service.EmployeeService">
<property name="employeeDao" ref="employeeDao"></property>
</bean> <bean id="employeeAction" class="com.dx.ssh.actions.EmployeeAction" scope="prototype">
<property name="employeeService" ref="employeeService"></property>
</bean>
</beans>

配置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>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" /> <package name="default" namespace="/" extends="struts-default">
<action name="emp-*" class="employeeAction" method="{1}">
<result name="list">/WEB-INF/views/emp-list.jsp</result>
</action>
</package>
</struts>

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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd"> <!-- 加载配置文件 -->
<context:property-placeholder location="classpath:jdbc.properties" file-encoding="utf-8" ignore-unresolvable="true" /> <!-- 配置数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClassName}"></property>
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="user" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<property name="testConnectionOnCheckout" value="${jdbc.c3p0.testConnectionOnCheckout}"></property>
<property name="testConnectionOnCheckin" value="${jdbc.c3p0.testConnectionOnCheckin}"></property>
<property name="idleConnectionTestPeriod" value="${jdbc.c3p0.idleConnectionTestPeriod}"></property>
<property name="initialPoolSize" value="${jdbc.c3p0.initialPoolSize}"></property>
<property name="minPoolSize" value="${jdbc.c3p0.minPoolSize}"></property>
<property name="maxPoolSize" value="${jdbc.c3p0.maxPoolSize}"></property>
<property name="maxIdleTime" value="${jdbc.c3p0.maxIdleTime}"></property>
</bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 数据源dataSource -->
<property name="dataSource" ref="dataSource" /> <!-- hibernate的配置方案一 -->
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
<!-- hibernate的配置方案二 -->
<!--
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
</props>
</property>
--> <!-- 持久化类的位置方案一,通过包进行扫描 -->
<property name="mappingLocations" value="classpath:com/dx/ssh/entities/*.hbm.xml"></property>
<!-- spring的spring.jar的jar包内,在org.springframework.orm.hibernate3.annotation下,
有一个AnnotationSessionFactoryBean类,其中有一个属性叫做"packagesToScan", 有个方法叫setpackagesToScan(),
也就是说我可以再spring里面将这个属性给设定上。
packagesToScan是"包扫描"的意思,哪些包spring可以给我们扫描一下,看看有哪些实体类,
这一项在我们在配置文件中配置hibernate的实体类的时候可以这么配,只要给出具体的扫描范围就可以了,
不需要将实体类一个一个的写出来
-->
<!-- 持久化类的位置方案二,通过包进行扫描 -->
<!--
<property name="packagesToScan">
<list>
<value>com.dx.ssh.entities</value>
</list>
</property>
-->
<!-- 持久化类的位置方案三,通过类进行扫描 -->
<!--
<property name="annotatedClasses">
<list>
<value>com.dx.ssh.entities.Member</value>
<value>com.dx.ssh.entities.Log</value>
</list>
</property>
-->
</bean>
<!-- 配置Hibernate事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <!-- 配置事务异常封装
<bean id="persistenceExceptionTranslationPostProcessor" class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
-->
<!-- 基于数据源的事务管理器 -->
<!--
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
-->
<!-- 启用注解来管理事务 --> <!-- 配合<tx:advice>和<aop:advisor>完成了事务切面的定义 -->
<!-- 使用强大的切点表达式是语言轻松定义目标方法 -->
<aop:config proxy-target-class="true">
<!-- 通过aop定义事务增强切面 -->
<aop:pointcut expression=" execution(* com.dx.ssh.service..*(..))" id="serviceMethod" />
<!-- 引用事务增强 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod" />
</aop:config>
<!-- 事务增强 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 事务属性定义 -->
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice> <!-- 第一种方式: 注解方式配置事物
<tx:annotation-driven transaction-manager="transactionManager" />
-->
</beans>

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!--
把一下配置信息转移到jdbc.properties中。
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123456</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/my_ssh</property>
--> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- <property name="hibernate.current_session_context_class">thread</property> -->
</session-factory>
</hibernate-configuration>

jdbc.properties

#-----------------------------------------------------
# \u6570\u636E\u5E93\u914D\u7F6E
#-----------------------------------------------------
#\u670D\u52A1\u5668\u5730\u5740
host=127.0.0.1
dbName=my_ssh
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://${host}:3306/${dbName}
jdbc.username=root
jdbc.password=123456 #-----------------------------------------------------
# \u9002\u7528\u4E8Ec3p0\u7684\u914D\u7F6E
#-----------------------------------------------------
#-----------------------------------------------------
# c3p0\u53CD\u7A7A\u95F2\u8BBE\u7F6E\uFF0C\u9632\u6B628\u5C0F\u65F6\u5931\u6548\u95EE\u989828800
#-----------------------------------------------------
#idleConnectionTestPeriod\u8981\u5C0F\u4E8EMySQL\u7684wait_timeout
jdbc.c3p0.testConnectionOnCheckout=false
jdbc.c3p0.testConnectionOnCheckin=true
jdbc.c3p0.idleConnectionTestPeriod=3600
#-----------------------------------------------------
# c3p0\u8FDE\u63A5\u6C60\u914D\u7F6E
#-----------------------------------------------------
#initialPoolSize, minPoolSize, maxPoolSize define the number of Connections that will be pooled.
#Please ensure that minPoolSize <= maxPoolSize.
#Unreasonable values of initialPoolSize will be ignored, and minPoolSize will be used instead.
jdbc.c3p0.initialPoolSize=10
jdbc.c3p0.minPoolSize=10
jdbc.c3p0.maxPoolSize=100
#maxIdleTime defines how many seconds a Connection should be permitted to go unused before being culled from the pool.
jdbc.c3p0.maxIdleTime=3600
#-----------------------------------------------------
# hibernate\u8FDE\u63A5\u6C60\u914D\u7F6E
#-----------------------------------------------------
hibernate.connection.driverClass=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://${host}:3306/${dbName}
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.hbm2ddl.auto=update

在WebContent下创建index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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>Insert title here</title>
</head>
<body>
<a href="emp-list">Employee List</a>
</body>
</html>

在WEB-INF下创建views文件夹,在views下创建emp-list.jsp页面

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!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>Insert title here</title>
</head>
<body>
<s:if test="#request.employees==null || #request.employees.size()==0">
暂无记录!
</s:if>
<s:else>
<table border="1" cellpadding="10" cellspacing="0">
<tr>
<td>ID</td>
<td>LastName</td>
<td>Email</td>
<td>BirthDay</td>
<td>CreateTime</td>
<td>Department Name</td>
<tr>
<s:iterator value="#request.employees">
<tr>
<td>${id }</td>
<td>${lastName }</td>
<td>${email }</td>
<td>${birth }</td>
<td>${createTime }</td>
<td>${department.deparmentName }</td>
<tr>
</s:iterator>
</table>
</s:else>
</body>
</html>

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_3_0.xsd" id="WebApp_ID"
version="3.0">
<display-name>My-SSH</display-name> <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index</welcome-file>
</welcome-file-list> <!-- 配置启动IOC容器的Listener -->
<!-- needed for ContextLoaderListener -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext*.xml</param-value>
</context-param> <!-- Bootstraps the root web application context before servlet initialization -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- Struts2 filter -->
<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> </web-app>

项目结构如下:

  • 测试结果:

  • 常见抛出异常情况:

1、nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

错误原因:缺少aspectjweaver-1.8.9.jar包导致的错误。

从地址http://repo1.maven.org/maven2/org/aspectj/aspectjweaver/,下载包aspectjweaver-1.8.9.jar。

2、Action class [userAction] not found - action

在做一个 ssh三个框架集成的时候,经常遇到上诉问题。如果已经正确定义了action,仍报错,其实是缺少包struts2-sping-plugin 2.0.1.jar

解决方案一:

上诉问题说的 在struts.xml 没用找到 sping配置文件里的一个bean啊;也就是说:struts.xml 这个文件没有和sping配置文件关联起来;

在此 另一种解决方案是 在 lib 目录下加入一个jar包struts2-sping-plugin 2.0.1.jar问题就解决了.

解决方案二:

在struts.xml中还要加入这么一个bean

<bean type="com.opensymphony.xwork2.ObjectFactory" name="spring
         class="org.apache.struts2.spring.StrutsSpringObjectFactory" />

这个bean要放在package的外面

3、Struts Problem Report

Struts has detected an unhandled exception:

Messages:
  • createQuery is not valid without active transaction
File: org/hibernate/context/internal/ThreadLocalSessionContext.java
Line number: 351

解决方案:

包hibernate.cfg.xml中的配置项注意掉:

<!-- <property name="hibernate.current_session_context_class">thread</property> -->

4、hibernate中采用了lazy加载,在查询hql=“From Employee e”,执行过程中dao被service调用,当action调用employeeService结束后,就立即关闭了session,导致页面没有版本加载数据导致的错误。

 Struts Problem Report

Struts has detected an unhandled exception:

Messages:
  1. could not initialize proxy - no Session
  2. Error reading 'deparmentName' on type com.dx.ssh.entities.Department_$$_jvst9ef_0
  3. javax.el.ELException: Error reading 'deparmentName' on type com.dx.ssh.entities.Department_$$_jvst9ef_0
File: org/hibernate/proxy/AbstractLazyInitializer.java
Line number: 146

解决该错误有三种解决方案:

解决方案一:修改Employee.hbm.xml man-to-one节点添加上属性 lazy="false",比较笨的方法。因为这是在用效率作为代价。

        <!-- 单项N:1关联关系 -->
<many-to-one name="department" class="com.dx.ssh.entities.Department" lazy="false">
<column name="DEPARTMENT_ID" />
</many-to-one>

解决方案二:使用OpenSessionInViewFilter。这种方法是将session交给servlet filter来管理,每当一个请求来之后就会开

启一个session,只有当响应结束后才会关闭。如下:

<filter-name>hibernateFilter</filter-name>
<filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class>
</filter
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

解决方案三:修改hql

    public List<Employee> getAll() {
String hql = "From Employee e LEFT OUTER JOIN FETCH e.department";
return getSession().createQuery(hql).list();
}

My-SSH项目源代码下载地址:http://pan.baidu.com/s/1o87Ezge

Spring(五):Spring&Struts2&Hibernate整合后,实现查询Employee信息的更多相关文章

  1. spring3 hibernate4整合后无法查询数据库

    spring3和hibernate4整合后无法查询数据库,一方面是因为已经spring3中没有对hibernate4 HibernateTemplate的支持,另外一个就是需要在hibernate的配 ...

  2. SSH框架之Spring+Struts2+Hibernate整合篇

    回顾 -Hibernate框架 ORM: 对象关系映射.把数据库表和JavaBean通过映射的配置文件映射起来, 操作JavaBean对象,通过映射的配置文件生成SQL语句,自动执行.操作数据库. 1 ...

  3. [Java web]Spring+Struts2+Hibernate整合过程

    摘要 最近一直在折腾java web相关内容,这里就把最近学习的spring+struts2+hibernate进行一个整合,也就是大家经常说的ssh. 环境 工具IDE :Idea 2018 数据库 ...

  4. struts2+hibernate整合-实现登录功能

    最近一直学习struts2+hibernate框架,于是想把两个框架整合到一起,做一个小的登录项目.其他不多说,直接看例子. 1).Struts2 和hibernate的环境配置 包括jar包.web ...

  5. [Java web]Spring+Struts2+Hibernate整合过程(2)

    摘要 上篇文章介绍了一种整合方式,不妨就叫做有hibernate配置文件的方式,这里介绍一种不用hibernate.cfg.xml的一种配置方式,为了方便,就仍在上篇的demo中,继续修改了. 步骤 ...

  6. spring+struts2+hibernate整合

    web.xml需要配置 <context-param> <param-name>contextConfigLocation</param-name> <par ...

  7. (Spring+IBatis+Struts1+Struts2+Hibernate+Java EE+Oracle)

    原文出处:http://space.itpub.net/6517/viewspace-609654 1.Spring架构图 Spring是一个开源框架,是为了解决企业应用程序开发复杂性而创建的.框架的 ...

  8. Spring、SpringMVC、Hibernate整合 ----超详细教程

    一.数据库表 /* Navicat MySQL Data Transfer Source Server : 本地连接 Source Server Version : 50720 Source Host ...

  9. struts2+hibernate整合开发步骤

    百度的各种代码,步骤,自己整合了一下 1,创建数据库 常用mysql   creat table..... 2,在WebContent下的bin中添加相应的包 http://pan.baidu.com ...

随机推荐

  1. gdb命令调试技巧

    gdb命令调试技巧 一.信息显示1.显示gdb版本 (gdb) show version2.显示gdb版权 (gdb) show version or show warranty3.启动时不显示提示信 ...

  2. Maven-06: 插件的内置绑定

    Maven的生命周期与插件相互绑定,用以完成实际的构建任务.具体而言,是生命周期的阶段与插件的目标相互绑定,以完成某个具体的构建任务.例如项目编译这一任务,它对应default生命周期的compile ...

  3. Tomcat下wtpwebapps文件夹 和 webapps文件夹区别

    这两者其实没有区别.都是项目部署路径 webapps : tomcat默认部署路径 wtpwebapps : eclipse默认部署路径 只不过Tomcat6将wtpwebapps作为了默认路径,如果 ...

  4. zabbix通过SNMP监控服务器硬件及构建触发器

    公司的服务器没装系统无法使用IPMI协议来监控服务器硬件信息,所以我们使用SNMP来获取,下面介绍如何通过SNMP监控服务器硬件信息. 1.HP服务器进入iLO开启SNMP协议. 2.查看服务器温度信 ...

  5. 云服务器Windows Server2012 配置http服务器(又称Web服务器,IIS)

    出错:无法打开运行空间池.服务器管理器WinRM插件可能已损坏或丢失. 解决方法: http://shiyousan.com/post/636308065767125916 第一步是开启WinRM服务 ...

  6. 在Python中进行JSON转化

    序列化,指的是把内存中的变量(如类的实例)变成可存储或可传输的过程. JSON(JavaScript Object Notation, JavaScript对象表示)是网络传输中经常使用的一种数据形式 ...

  7. Comparable接口和Comparator接口

    1.一个类在设计之初就要实现对该类对象的排序功能,那么这个类要实现Comparable接口,实现public int compareTo(T t)方法.如代码中的Student类.对于实现Compar ...

  8. Mybatis学习笔记二

    本篇内容,紧接上一篇内容Mybatis学习笔记一 输入映射和输出映射 传递简单类型和pojo类型上篇已介绍过,下面介绍一下包装类型. 传递pojo包装对象 开发中通过可以使用pojo传递查询条件.查询 ...

  9. JavaWeb学习笔记九 过滤器、注解

    过滤器Filter filter是对客户端访问资源的过滤,符合条件放行,不符合条件不放行,并且可以对目标资源访问前后进行逻辑处理. 步骤: 编写一个过滤器的类实现Filter接口 实现接口中尚未实现的 ...

  10. (译文)React----React应用程序流式服务端渲染

    好处 React16推出了流式服务端渲染,它允许你并行地分发HTML片段.这样可以让渲染 出的首字节有意义的内容给用户速度更快. (例子1,上面部分是一次性转换,下面是流渲染,两种方式) 而且相对re ...