Spring4 MVC Hibernate4集成 Annotation

一、    本文所用环境

Spring4.0.3.RELEASE、Hibernate4.3.5.Final、Mysql

二、    工程目录

三、    Maven添加依赖

用Maven创建项目,pom.xml如下:

 

四、    新建数据库表

数据库采用Mysql,新建user表,我们演示操作此表对user进行增删改查

DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `age` int(11) DEFAULT NULL,
  `nice_name` varchar(32) DEFAULT NULL,
  `name` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8;

在model层下,创建Entity类Users.java见下

package com.lei.demo.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity(name="User")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    public User(){
        super();
    }

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="id")
    private Long id;

    @Column(name="name",length=32)
    private String name;

    @Column(name="age")
    private Integer age;

    @Column(name="nice_name",length=32)
    private String nice_name;

    @Override
    public String toString() {
        return "User [id=" + id + ", user_name=" + name + ", age=" + age
                + ", nice_name=" + nice_name + "]";
    }

    public final Long getId() {
        return id;
    }

    public final void setId(Long id) {
        this.id = id;
    }

    public final String getName() {
        return name;
    }

    public final void setName(String name) {
        this.name = name;
    }

    public final Integer getAge() {
        return age;
    }

    public final void setAge(Integer age) {
        this.age = age;
    }

    public final String getNice_name() {
        return nice_name;
    }

    public final void setNice_name(String nice_name) {
        this.nice_name = nice_name;
    }

}

五、    配置文件

1.        首先看一下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"
    xmlns:web="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>Archetype Created Web Application</display-name>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:/spring-*.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <!-- 定义DispatcherServlet -->
  <servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <!-- 默认/WEB-INF/[servlet名字]-servlet.xml加载上下文,
          如果配置了contextConfigLocation参数,
          将使用classpath:/mvc-dispatcher-servlet.xml加载上下文
      -->
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:/mvc-dispatcher-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <!-- 拦截匹配的请求,这里所有请求采用名字为mvc-dispatcher的DispatcherServlet处理 -->
  <servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

2.        mvc-dispatcher-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
        ">

    <!-- 启动自动扫描该包下所有的Bean(例如@Controller) -->
    <context:component-scan base-package="com.lei.demo" />

    <!-- 基于注释的事务,当注释中发现@Transactional时,使用id为“transactionManager”的事务管理器  -->
    <!-- 如果没有设置transaction-manager的值,则spring以缺省默认的事务管理器来处理事务,默认事务管理器为第一个加载的事务管理器 -->
    <tx:annotation-driven transaction-manager="transactionManager"/>

    <!-- 定义视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/jsp/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>

</beans>

3.        Spring-hibernate的整合

spring-hibernate.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
        ">

    <!-- Hibernate4 -->
    <!-- 加载资源文件  其中包含变量信息,必须在Spring配置文件的最前面加载,即第一个加载-->
    <context:property-placeholder location="classpath:persistence-mysql.properties" />

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan">
            <list>
                <!-- 可以加多个包 -->
                <value>com.lei.demo.model</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            </props>
        </property>
    </bean>

    <!-- 数据库映射 -->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="${jdbc.driverClassName}" />
      <property name="url" value="${jdbc.url}" />
      <property name="username" value="${jdbc.user}" />
      <property name="password" value="${jdbc.pass}" />
   </bean>

    <!-- 配置Hibernate事务管理器 -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
      <property name="sessionFactory" ref="sessionFactory" />
   </bean>

   <!-- 配置事务异常封装 -->
   <bean id="persistenceExceptionTranslationPostProcessor"
       class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />

</beans>

资源文件persistence-mysql.properties如下:

# jdbc.X
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://192.168.150.63:3306/test?createDatabaseIfNotExist=true
jdbc.user=root
jdbc.pass=root111111

# hibernate.X
hibernate.connection.driverClass=org.gjt.mm.mysql.Driver
hibernate.connection.url=jdbc:mysql://192.168.150.63:3306/test
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.connection.username=root
hibernate.connection.password=root111111
hibernate.show_sql=true

六、    Model层

此处model层只有一个User类,见前文user.java。

七、    DAO层

DAO层包括3个包,各个包中类如下:

com.lei.demo.dao.common: IOperations, AbstractHibernateDao

com.lei.demo.dao: IUserDao

com.lei.demo.dao.impl: UserDao

代码如下:

IOperations.java,通用的操作接口

package com.lei.demo.dao.common;

import java.io.Serializable;
import java.util.List;

/*
 * 通用的操作接口
 */
public interface IOperations<T extends Serializable> {

        T findOne(final long id);

        List<T> findAll();

        void create(final T entity);

        T update(final T entity);

        void delete(final T entity);

        void deleteById(final long entityId);

}

AbstractHibernateDao.java实现了IOperations接口,所有DAO都需要继承此类,这样就避免重复的写一些CURD。

package com.lei.demo.dao.common;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.google.common.base.Preconditions;

@SuppressWarnings("unchecked")
public abstract class AbstractHibernateDao<T extends Serializable> implements IOperations<T> {

    private Class<T> clazz;

    @Resource(name="sessionFactory")
    private SessionFactory sessionFactory;

    protected final void setClazz(final Class<T> clazzToSet) {
        this.clazz = Preconditions.checkNotNull(clazzToSet);
    }

    protected final Session getCurrentSession() {
        return sessionFactory.getCurrentSession();
    }

    @Override
    public final T findOne(final long id) {
        return (T)getCurrentSession().get(clazz, id);
    }

    @Override
    public final List<T> findAll() {
        return getCurrentSession().createQuery("from " + clazz.getName()).list();
    }

    @Override
    public final void create(final T entity) {
         Preconditions.checkNotNull(entity);
         // getCurrentSession().persist(entity);
         getCurrentSession().saveOrUpdate(entity);
    }

    @Override
    public final T update(final T entity) {
        Preconditions.checkNotNull(entity);
        getCurrentSession().update(entity);
        return entity;
        //return (T)getCurrentSession().merge(entity);
    }

    @Override
    public final void delete(final T entity) {
         Preconditions.checkNotNull(entity);
         getCurrentSession().delete(entity);
    }

    @Override
    public final void deleteById(final long entityId) {
        final T entity = findOne(entityId);
        Preconditions.checkState(entity != null);
        delete(entity);
    }

}

IUserDao.java具体的DAO的接口,继承了IOperations

package com.lei.demo.dao;

import com.lei.demo.dao.common.IOperations;
import com.lei.demo.model.User;

public interface IUserDao extends IOperations<User> {
    //让所有的DAO都实现基本的操作接口IOperations
    //除了实现IOperations中的基本操作之外,特定的DAO要实现其他操作可以在对应的接口DAO中定义方法,
    //此处UserDao的接口IUserDao不需要实现其他方法
}

UserDao.java具体的DAO实现

package com.lei.demo.dao.impl;

import org.springframework.stereotype.Repository;

import com.lei.demo.dao.IUserDao;
import com.lei.demo.dao.common.AbstractHibernateDao;
import com.lei.demo.model.User;

@Repository("usersDao")
public class UserDao extends AbstractHibernateDao<User> implements IUserDao {

    public UserDao() {
        super();

        setClazz(User.class);
    }
}

至此,DAO层已经完成。

八、    Service层

Service层包括3个包,各个包中类如下:

com.lei.demo.service.common: AbstractService

com.lei.demo.service: IUserService

com.lei.demo.service.impl: UserService

AbstractService.java,实现了IOperations,所有的Service都要继承此类,这样就避免了重复实现通用的方法,注意类前的注释“@Transactional

”,表示其中所有的方法都需要引入事务,代码如下:

package com.lei.demo.service.common;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.lei.demo.dao.common.IOperations;

@Transactional
public abstract class AbstractService<T extends Serializable> implements IOperations<T> {

    protected abstract IOperations<T> getDao();

    @Override
    public T findOne(final long id) {
        return getDao().findOne(id);
    }

    @Override
    public List<T> findAll() {
        return getDao().findAll();
    }

    @Override
    public void create(final T entity) {
        getDao().create(entity);
    }

    @Override
    public T update(final T entity) {
        return getDao().update(entity);
    }

    @Override
    public void delete(final T entity) {
        getDao().delete(entity);
    }

    @Override
    public void deleteById(long entityId) {
        getDao().deleteById(entityId);
    }

}

IUserService.java接口

package com.lei.demo.service;

import com.lei.demo.dao.common.IOperations;
import com.lei.demo.model.User;

public interface IUserService extends IOperations<User> {

}

UserService.java,具体的Service实现类就很简单了,因为大部分通用的方法都在其继承的虚类AbstractService中实现了,这里只要注入具体的dao即可:

package com.lei.demo.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lei.demo.dao.IUserDao;
import com.lei.demo.dao.common.IOperations;
import com.lei.demo.model.User;
import com.lei.demo.service.IUserService;
import com.lei.demo.service.common.AbstractService;

@Service("userService")
public class UserService extends AbstractService<User> implements IUserService {

    @Resource(name="usersDao")
    private IUserDao dao;

    public UserService() {
        super();
    }

    @Override
    protected IOperations<User> getDao() {
        return this.dao;
    }
}

九、    JSP页面和Controller

Jsp页面放在WEB-INF/jsp/user/…下,分别是user的增删改查页面,

WEB-INF/jsp/user/add.jsp

WEB-INF/jsp/user/edit.jsp

WEB-INF/jsp/user/list.jsp

WEB-INF/jsp/user/detail.jsp

以下是具体页面代码

WEB-INF/jsp/user/add.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!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>Add User</title>
</head>
<body>
    <form action="add" method="post">

        Name:<input id="name" name="name" type="text" />
        <br>
        Nice Name:<input id="nice_name" name="nice_name" type="text" />
        <br>
        Age:<input id="age" name="age" type="text" />
        <br>
        <input type="submit" value="提交">
    </form>
</body>
</html>

WEB-INF/jsp/user/edit.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!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>Edit user</title>
</head>
<body>
    <c:url var="saveUrl" value="/user/save/${userAttribute.id }" />
    <form:form modelAttribute="userAttribute" action="${saveUrl }">
        <table>
            <tr>
                <td>ID:</td>
                <td><form:input path="id" readonly="true"/></td>
            </tr>
            <tr>
                <td>Name:</td>
                <td><form:input path="name"/></td>
            </tr>
            <tr>
                <td>Nice name:</td>
                <td><form:input path="nice_name"/></td>
            </tr>
            <tr>
                <td>Age:</td>
                <td><form:input path="age"/></td>
            </tr>
        </table>
        <input type="submit" value="Save">
    </form:form>
</body>
</html>

WEB-INF/jsp/user/list.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!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>User List</title>
</head>
<body>
    <a href="add">Add</a>
    <table>
        <tr>
            <td>ID</td>
            <td>Name</td>
            <td>NiceName</td>
            <td>Age</td>
        </tr>
        <c:forEach var="user" items="${userList }" >
            <tr>
                <td>${user.id }</td>
                <td>${user.name }</td>
                <td>${user.nice_name }</td>
                <td>${user.age }</td>
                <td><a href="show/${user.id }">详细</a></td>
                <td><a href="edit/${user.id }">编辑</a></td>
                <td><a href="del/${user.id }">删除</a></td>
            </tr>
        </c:forEach>
    </table>
</body>
</html>

WEB-INF/jsp/user/detail.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!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>Show user</title>
</head>
<body>
    <c:out value="${user.id }"></c:out>
    <br>
    <c:out value="${user.name }"></c:out>
    <br>
    <c:out value="${user.nice_name }"></c:out>
    <br>
    <c:out value="${user.age }"></c:out>
</body>
</html>

写Controller访问上边的jsp,UserController.java

package com.lei.demo.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.lei.demo.model.User;
import com.lei.demo.service.IUserService;

@Controller
@RequestMapping("/user")
public class UserController {

    @Resource(name="userService")
    private IUserService userService;

    @RequestMapping(value="/count",method=RequestMethod.GET)
    public ModelAndView userCount() {

        int count = userService.findAll().size();

        ModelAndView mv = new ModelAndView();
        mv.addObject("userCount", count);
        mv.setViewName("user/userCount");
        return mv;
    }

    @RequestMapping(value="/list",method=RequestMethod.GET)
    public ModelAndView getUserlist(Model model){

        ModelAndView mv = new ModelAndView();
        List<User> userList = userService.findAll();
        System.out.println("log======table 'user' all records:"+userList.size());
        mv.addObject("userList", userList);
        mv.setViewName("user/list");
        return mv;
    }

    @RequestMapping(value="/add",method=RequestMethod.GET)
    public ModelAndView getAdd(){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("user/add");
        return mv;
    }

    @RequestMapping(value="/add",method=RequestMethod.POST)
    public String add(@ModelAttribute("user") User user){
        userService.create(user);
        return "redirect:/user/list";
    }

    @RequestMapping(value="/show/{userid}",method=RequestMethod.GET)
    public ModelAndView show(@PathVariable Long userid){
        User user = userService.findOne(userid);

        ModelAndView mv = new ModelAndView();
        mv.addObject("user", user);
        mv.setViewName("user/detail");
        return mv;
    }

    @RequestMapping(value="/del/{userid}",method=RequestMethod.GET)
    public String del(@PathVariable Long userid){
        userService.deleteById(userid);

        return "redirect:/user/list";
    }

    @RequestMapping(value="/edit/{userid}",method=RequestMethod.GET)
    public ModelAndView getEdit(@PathVariable Long userid,Model model){
        User user = userService.findOne(userid);
        model.addAttribute("userAttribute", user);
        ModelAndView mv = new ModelAndView();
        mv.setViewName("user/edit");
        return mv;
    }

    @RequestMapping(value="/save/{userid}",method=RequestMethod.POST)
    public String saveEdit(@ModelAttribute("userAttribute") User user,@PathVariable Long userid){
        userService.update(user);
        return "redirect:/user/list";
    }
}

十、    运行结果

原文链接:http://www.cnblogs.com/leiOOlei/p/3780290.html

Hibernate4集成 Annotation使用教程的更多相关文章

  1. Spring4 MVC Hibernate4集成 Annotation

    Spring4 MVC Hibernate4集成 Annotation 一.本文所用环境 二.工程目录 三.Maven添加依赖 四.新建数据库表 五.配置文件 六.Model层 七.DAO层 八.Se ...

  2. Spring4 MVC Hibernate4集成

      Spring4 MVC Hibernate4集成 一.    本文所用环境 Spring4.0.3.RELEASE Hibernate4.3.5.Final Mysql 二.    工程目录 三. ...

  3. 移动应用开发测试工具Bugtags集成和使用教程

    前段时间,有很多APP突然走红,最终却都是樱花一现.作为一个创业团队,突然爆红是非常难得的机会.然并卵,由于没有经过充分的测试,再加上用户的激增,APP闪退.服务器数据异常等问题就被暴露出来,用户的流 ...

  4. Struts2+Spring4+Hibernate4整合超详细教程

    Struts2.Spring4.Hibernate4整合 超详细教程 Struts2.Spring4.Hibernate4整合实例-下载 项目目的: 整合使用最新版本的三大框架(即Struts2.Sp ...

  5. spring+springMVC集成(annotation方式)

    spring+springMVC集成(annotation方式) SpringMVC+Spring4.0+Hibernate 简单的整合 MyBatis3整合Spring3.SpringMVC3

  6. Hibernate4集成spring4报错----No Session found for current thread

    在编写一个Hibernate4集成spring4的小demo的时候出现了该错误: org.hibernate.HibernateException: No Session found for curr ...

  7. 移动应用开发测试工具Bugtags集成和使用教程【转载】

    前段时间,有很多APP突然走红,最终却都是樱花一现.作为一个创业团队,突然爆红是非常难得的机会.然并卵,由于没有经过充分的测试,再加上用户的激增,APP闪退.服务器数据异常等问题就被暴露出来,用户的流 ...

  8. Spring Data JPA系列2:SpringBoot集成JPA详细教程,快速在项目中熟练使用JPA

    大家好,又见面了. 这是Spring Data JPA系列的第2篇,在上一篇<Spring Data JPA系列1:JDBC.ORM.JPA.Spring Data JPA,傻傻分不清楚?给你个 ...

  9. elastic-job集成到springboot教程,和它的一个异常处理办法:Sharding item parameters '1' format error, should be int=xx,int=xx

    先说这个Sharding item parameters '1' format error, should be int=xx,int=xx异常吧,这是在做动态添加调度任务的时候出现的,网上找了一会没 ...

随机推荐

  1. zabbix源码安装

    Zabbix通过C/S模式采集数据,通过B/S模式在web端展示和配置. 被监控端:主机通过安装agent方式采集数据,网络设备通过SNMP方式采集数据 Server端:通过收集SNMP和agent发 ...

  2. webapi获取请求地址的IP

    References required: HttpContextWrapper - System.Web.dll RemoteEndpointMessageProperty - System.Serv ...

  3. VS 6.00 工程项目文件详解

    *.dsp(DeveloperStudio Project):是VC++的工程配置文件,比如说你的工程包含哪个文件,你的编译选项是什么等等,编译的时候是按照.dsp的配置来的.*.dsw(Develo ...

  4. 使用crontab不能正常执行的问题

    crontab -l:   列出当前用户的crontab列表crontab -e:   以vi打开crontab文件,可以进行编辑.如果需要加新的自启动项目,可以在此进行添加后再输入:wq 保存. & ...

  5. hdwiki中插件开发指南

    插件就是为了满足个性化需求按照HDWiki插件开发规范编写的可插拔程序,虽然可以直接对HDWiki进行二次开发实现插件同样的功能,但是这样做势必影响到系统的升级和稳定性. 采用插件的方式,可以随时进行 ...

  6. 层叠样式表(CSS)

    层叠样式表(CSS) CSS(Cascading Style Sheet)中文译为层叠样式表.是用于控制网页样式并允许将样式信息与网页内容分离的一种标记性语言.CSS的引入就是为了使得HTML语言能够 ...

  7. css中transition的使用以及:before:after的使用(小样式)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  8. hdoj4906 Our happy ending(2014 Multi-University Training Contest 4)

    对于一个定长(size = n)的数列a, 若其存在“位置相关”的子集(含空集)使得该子集所有元素之和为k,那么将数列a计数. 其中数列a中任一元素a[i]在[0, l]内自由取值. 数据条件0≤n, ...

  9. 山东理工大学第七届ACM校赛-LCM的个数 分类: 比赛 2015-06-26 10:37 18人阅读 评论(0) 收藏

    LCM的个数 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 对于我们来说求两个数的LCM(最小公倍数)是很容易的事,现在我遇到了 ...

  10. livereload的简单使用

    一/直接使用:npm install -g livereload 全局安装 http-server  起到服务 livereload启动 在html中引入<script src="ht ...