SPRING IN ACTION 第4版笔记-第十一章Persisting data with object-relational mapping-005Spring-Data-JPA例子的代码
一、结构
二、Repository层
1.
package spittr.db; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import spittr.domain.Spitter; /**
* Repository interface with operations for {@link Spitter} persistence.
* @author habuma
*/
public interface SpitterRepository extends JpaRepository<Spitter, Long>, SpitterSweeper { Spitter findByUsername(String username); List<Spitter> findByUsernameOrFullNameLike(String username, String fullName); }
2.
package spittr.db; public interface SpitterSweeper { int eliteSweep(); }
3.
package spittr.db; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; public class SpitterRepositoryImpl implements SpitterSweeper { @PersistenceContext
private EntityManager em; public int eliteSweep() {
String update =
"UPDATE Spitter spitter " +
"SET spitter.status = 'Elite' " +
"WHERE spitter.status = 'Newbie' " +
"AND spitter.id IN (" +
"SELECT s FROM Spitter s WHERE (" +
" SELECT COUNT(spittles) FROM s.spittles spittles) > 10000" +
")";
return em.createQuery(update).executeUpdate();
} }
4.
package spittr.db; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import spittr.domain.Spittle; /**
* Repository interface with operations for {@link Spittle} persistence.
* @author habuma
*/
public interface SpittleRepository extends JpaRepository<Spittle, Long>, SpittleRepositoryCustom { List<Spittle> findBySpitterId(long spitterId); }
5.
package spittr.db; import java.util.List; import spittr.domain.Spittle; public interface SpittleRepositoryCustom { List<Spittle> findRecent(); List<Spittle> findRecent(int count); }
6.
package spittr.db; import java.util.List; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import spittr.domain.Spittle; public class SpittleRepositoryImpl implements SpittleRepositoryCustom { @PersistenceContext
private EntityManager entityManager; public List<Spittle> findRecent() {
return findRecent(10);
} public List<Spittle> findRecent(int count) {
return (List<Spittle>) entityManager.createQuery("select s from Spittle s order by s.postedTime desc")
.setMaxResults(count)
.getResultList();
} }
三、domain层
1.
package spittr.domain; import java.util.List; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany; @Entity
public class Spitter { private Spitter() {} @Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id; @Column(name="username")
private String username; @Column(name="password")
private String password; @Column(name="fullname")
private String fullName; @Column(name="email")
private String email; @Column(name="updateByEmail")
private boolean updateByEmail; @Column(name="status")
private String status; @OneToMany(targetEntity=Spittle.class, fetch=FetchType.EAGER, mappedBy="spitter")
private List<Spittle> spittles; public Spitter(Long id, String username, String password, String fullName,
String email, boolean updateByEmail) {
this.id = id;
this.username = username;
this.password = password;
this.fullName = fullName;
this.email = email;
this.updateByEmail = updateByEmail;
this.status = "Newbie";
} public Long getId() {
return id;
} public String getUsername() {
return username;
} public String getPassword() {
return password;
} public String getFullName() {
return fullName;
} public String getEmail() {
return email;
} public boolean isUpdateByEmail() {
return updateByEmail;
} public String getStatus() {
return status;
} public List<Spittle> getSpittles() {
return spittles;
}
}
2.
package spittr.domain; import java.util.Date; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; @Entity
public class Spittle { @Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id; @ManyToOne
@JoinColumn(name="spitter")
private Spitter spitter; @Column
private String message; @Column
private Date postedTime; private Spittle() {} public Spittle(Long id, Spitter spitter, String message, Date postedTime) {
this.id = id;
this.spitter = spitter;
this.message = message;
this.postedTime = postedTime;
} public Long getId() {
return this.id;
} public String getMessage() {
return this.message;
} public Date getPostedTime() {
return this.postedTime;
} public Spitter getSpitter() {
return this.spitter;
} }
四、配置文件及数据库文件
1.
package spittr.db; import javax.sql.DataSource; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; @Configuration
@EnableJpaRepositories(basePackages="spitter.db")
public class SpringDataJpaConfig { @Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder()
.addScript("classpath:spitter/db/jpa/schema.sql")
.addScript("classpath:spitter/db/jpa/test-data.sql")
.build();
} @Bean
public JpaTransactionManager transactionManager() {
return new JpaTransactionManager(); // does this need an emf???
} @Bean
public HibernateJpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
adapter.setDatabase(Database.H2);
adapter.setShowSql(false);
adapter.setGenerateDdl(true);
return adapter;
} @Bean
public Object emf() {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource());
emf.setPersistenceUnitName("spitter");
emf.setJpaVendorAdapter(jpaVendorAdapter());
return emf;
} }
2.
package spittr.db.jpa; import javax.inject.Inject;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration
@EnableJpaRepositories(basePackages="spittr.db")
public class JpaConfig { @Bean
public DataSource dataSource() {
EmbeddedDatabaseBuilder edb = new EmbeddedDatabaseBuilder();
edb.setType(EmbeddedDatabaseType.H2);
edb.addScript("spittr/db/jpa/schema.sql");
edb.addScript("spittr/db/jpa/test-data.sql");
EmbeddedDatabase embeddedDatabase = edb.build();
return embeddedDatabase;
} @Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource);
emf.setPersistenceUnitName("spittr");
emf.setJpaVendorAdapter(jpaVendorAdapter);
emf.setPackagesToScan("spittr.domain");
return emf;
} @Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
adapter.setDatabase(Database.H2);
adapter.setShowSql(true);
adapter.setGenerateDdl(false);
adapter.setDatabasePlatform("org.hibernate.dialect.H2Dialect");
return adapter;
} @Configuration
@EnableTransactionManagement
public static class TransactionConfig { @Inject
private EntityManagerFactory emf; @Bean
public PlatformTransactionManager transactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);
return transactionManager;
}
} }
3.RepositoryTest-context.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:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <jpa:repositories base-package="spittr.db" /> <bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource"
p:persistenceUnitName="spitter"
p:jpaVendorAdapter-ref="jpaVendorAdapter" /> <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="H2" />
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
</bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="emf" /> <jdbc:embedded-database id="dataSource" type="H2">
<jdbc:script location="spittr/db/jpa/schema.sql" />
<jdbc:script location="spittr/db/jpa/test-data.sql" />
</jdbc:embedded-database> </beans>
4.schema.sql
drop table if exists spittle;
drop table if exists spitter; create table spitter (
id identity,
username varchar(25) not null,
password varchar(25) not null,
fullName varchar(100) not null,
email varchar(50) not null,
updateByEmail boolean not null,
status varchar(10) not null
); create table spittle (
id integer identity primary key,
spitter integer not null,
message varchar(2000) not null,
postedTime datetime not null,
foreign key (spitter) references spitter(id)
);
5.test-data.sql
insert into Spitter (username, password, fullname, email, updateByEmail, status) values ('habuma', 'password', 'Craig Walls', 'craig@habuma.com', false, 'Newbie');
insert into Spitter (username, password, fullname, email, updateByEmail, status) values ('mwalls', 'password', 'Michael Walls', 'mwalls@habuma.com', true, 'Newbie');
insert into Spitter (username, password, fullname, email, updateByEmail, status) values ('chuck', 'password', 'Chuck Wagon', 'chuck@habuma.com', false, 'Newbie');
insert into Spitter (username, password, fullname, email, updateByEmail, status) values ('artnames', 'password', 'Art Names', 'art@habuma.com', true, 'Newbie'); insert into Spittle (spitter, message, postedTime) values (1, 'This is a test spittle message', '2012-06-09 22:00:00Z');
insert into Spittle (spitter, message, postedTime) values (1, 'This is another test spittle message', '2012-06-09 22:10:00Z');
insert into Spittle (spitter, message, postedTime) values (1, 'This is a third test spittle message', '2012-07-04 23:30:00Z');
insert into Spittle (spitter, message, postedTime) values (2, 'Hello from Chuck!', '2012-03-25 12:15:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Hello from Art!', '2012-03-25 12:15:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Hello again from Art!', '2012-03-25 12:25:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Hola from Arthur!', '2012-03-25 12:35:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Buenos Dias from Art!', '2012-03-25 12:45:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Ni Hao from Art!', '2012-03-25 12:55:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Guten Tag from Art!', '2012-03-25 13:05:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Konnichi wa from Art!', '2012-03-25 13:15:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Buon giorno from Art!', '2012-03-25 13:25:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Bonjour from Art!', '2012-03-25 13:35:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Aloha from Art!', '2012-03-25 13:45:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'God dag from Art!', '2012-03-25 13:55:00Z');
6.
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %40.40c:%4L - %m%n log4j.rootLogger=WARN,stdout log4j.category.org.hibernate=WARN
五、测试文件
1.
package spittr.db.jpa; import static org.junit.Assert.*; import java.util.List; import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional; import spittr.db.SpitterRepository;
import spittr.db.SpringDataJpaConfig;
import spittr.domain.Spitter; @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes=SpringDataJpaConfig.class)
public class SpitterRepositoryTest { @Autowired
SpitterRepository spitterRepository; @Test
@Transactional
public void count() {
assertEquals(4, spitterRepository.count());
} @Test
@Transactional
public void findAll() {
List<Spitter> spitters = spitterRepository.findAll();
assertEquals(4, spitters.size());
assertSpitter(0, spitters.get(0));
assertSpitter(1, spitters.get(1));
assertSpitter(2, spitters.get(2));
assertSpitter(3, spitters.get(3));
} @Test
@Transactional
public void findByUsername() {
assertSpitter(0, spitterRepository.findByUsername("habuma"));
assertSpitter(1, spitterRepository.findByUsername("mwalls"));
assertSpitter(2, spitterRepository.findByUsername("chuck"));
assertSpitter(3, spitterRepository.findByUsername("artnames"));
} @Test
@Transactional
public void findOne() {
assertSpitter(0, spitterRepository.findOne(1L));
assertSpitter(1, spitterRepository.findOne(2L));
assertSpitter(2, spitterRepository.findOne(3L));
assertSpitter(3, spitterRepository.findOne(4L));
} @Test
@Transactional
public void save_newSpitter() {
assertEquals(4, spitterRepository.count());
Spitter spitter = new Spitter(null, "newbee", "letmein", "New Bee", "newbee@habuma.com", true);
Spitter saved = spitterRepository.save(spitter);
assertEquals(5, spitterRepository.count());
assertSpitter(4, saved);
assertSpitter(4, spitterRepository.findOne(5L));
} @Test
@Transactional
@Ignore
public void save_existingSpitter() {
assertEquals(4, spitterRepository.count());
Spitter spitter = new Spitter(4L, "arthur", "letmein", "Arthur Names", "arthur@habuma.com", false);
Spitter saved = spitterRepository.save(spitter);
assertSpitter(5, saved);
assertEquals(4, spitterRepository.count());
Spitter updated = spitterRepository.findOne(4L);
assertSpitter(5, updated);
} private static void assertSpitter(int expectedSpitterIndex, Spitter actual) {
assertSpitter(expectedSpitterIndex, actual, "Newbie");
} private static void assertSpitter(int expectedSpitterIndex, Spitter actual, String expectedStatus) {
Spitter expected = SPITTERS[expectedSpitterIndex];
assertEquals(expected.getId(), actual.getId());
assertEquals(expected.getUsername(), actual.getUsername());
assertEquals(expected.getPassword(), actual.getPassword());
assertEquals(expected.getFullName(), actual.getFullName());
assertEquals(expected.getEmail(), actual.getEmail());
assertEquals(expected.isUpdateByEmail(), actual.isUpdateByEmail());
} private static Spitter[] SPITTERS = new Spitter[6]; @BeforeClass
public static void before() {
SPITTERS[0] = new Spitter(1L, "habuma", "password", "Craig Walls", "craig@habuma.com", false);
SPITTERS[1] = new Spitter(2L, "mwalls", "password", "Michael Walls", "mwalls@habuma.com", true);
SPITTERS[2] = new Spitter(3L, "chuck", "password", "Chuck Wagon", "chuck@habuma.com", false);
SPITTERS[3] = new Spitter(4L, "artnames", "password", "Art Names", "art@habuma.com", true);
SPITTERS[4] = new Spitter(5L, "newbee", "letmein", "New Bee", "newbee@habuma.com", true);
SPITTERS[5] = new Spitter(4L, "arthur", "letmein", "Arthur Names", "arthur@habuma.com", false);
} }
2.
package spittr.db.jpa; import static org.junit.Assert.*; import java.util.Date;
import java.util.List; import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional; import spittr.db.SpittleRepository;
import spittr.domain.Spitter;
import spittr.domain.Spittle; @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes=JpaConfig.class)
public class SpittleRepositoryTest { @Autowired
SpittleRepository spittleRepository; @Test
@Transactional
public void count() {
assertEquals(15, spittleRepository.count());
} @Test
@Transactional
public void findRecent() {
// default case
{
List<Spittle> recent = spittleRepository.findRecent();
assertRecent(recent, 10);
} // specific count case
{
List<Spittle> recent = spittleRepository.findRecent(5);
assertRecent(recent, 5);
}
} @Test
@Transactional
public void findOne() {
Spittle thirteen = spittleRepository.findOne(13L);
assertEquals(13, thirteen.getId().longValue());
assertEquals("Bonjour from Art!", thirteen.getMessage());
assertEquals(1332682500000L, thirteen.getPostedTime().getTime());
assertEquals(4, thirteen.getSpitter().getId().longValue());
assertEquals("artnames", thirteen.getSpitter().getUsername());
assertEquals("password", thirteen.getSpitter().getPassword());
assertEquals("Art Names", thirteen.getSpitter().getFullName());
assertEquals("art@habuma.com", thirteen.getSpitter().getEmail());
assertTrue(thirteen.getSpitter().isUpdateByEmail());
} @Test
@Transactional
public void findBySpitter() {
List<Spittle> spittles = spittleRepository.findBySpitterId(4L);
assertEquals(11, spittles.size());
for (int i = 0; i < 11; i++) {
assertEquals(i+5, spittles.get(i).getId().longValue());
}
} @Test
@Transactional
public void save() {
assertEquals(15, spittleRepository.count());
Spitter spitter = spittleRepository.findOne(13L).getSpitter();
Spittle spittle = new Spittle(null, spitter, "Un Nuevo Spittle from Art", new Date());
Spittle saved = spittleRepository.save(spittle);
assertEquals(16, spittleRepository.count());
assertNewSpittle(saved);
assertNewSpittle(spittleRepository.findOne(16L));
} @Test
@Transactional
public void delete() {
assertEquals(15, spittleRepository.count());
assertNotNull(spittleRepository.findOne(13L));
spittleRepository.delete(13L);
assertEquals(14, spittleRepository.count());
assertNull(spittleRepository.findOne(13L));
} private void assertRecent(List<Spittle> recent, int count) {
long[] recentIds = new long[] {3,2,1,15,14,13,12,11,10,9};
assertEquals(count, recent.size());
for (int i = 0; i < count; i++) {
assertEquals(recentIds[i], recent.get(i).getId().longValue());
}
} private void assertNewSpittle(Spittle spittle) {
assertEquals(16, spittle.getId().longValue());
} }
SPRING IN ACTION 第4版笔记-第十一章Persisting data with object-relational mapping-005Spring-Data-JPA例子的代码的更多相关文章
- SPRING IN ACTION 第4版笔记-第十一章Persisting data with object-relational mapping-006Spring-Data的运行规则(@EnableJpaRepositories、<jpa:repositories>)
一.JpaRepository 1.要使Spring自动生成实现类的步骤 (1)配置文件xml <?xml version="1.0" encoding="UTF- ...
- SPRING IN ACTION 第4版笔记-第十一章Persisting data with object-relational mapping-003编写JPA-based repository( @PersistenceUnit、 @PersistenceContext、PersistenceAnnotationBeanPostProcessor)
一.注入EntityManagerFactory的方式 package com.habuma.spittr.persistence; import java.util.List; import jav ...
- SPRING IN ACTION 第4版笔记-第十一章Persisting data with object-relational mapping-002设置JPA的EntityManagerFactory(<persistence-unit>、<jee:jndi-lookup>)
一.EntityManagerFactory的种类 1.The JPA specification defines two kinds of entity managers: Applicatio ...
- SPRING IN ACTION 第4版笔记-第十一章Persisting data with object-relational mapping-001-使用Hibernate(@Inject、@EnableTransactionManagement、@Repository、PersistenceExceptionTranslationPostProcessor)
一.结构 二.Repository层 1. package spittr.db; import java.util.List; import spittr.domain.Spitter; /** * ...
- SPRING IN ACTION 第4版笔记-第十一章Persisting data with object-relational mapping-004JPA例子的代码
一.结构 二.Repository层 1. package spittr.db; import java.util.List; import spittr.domain.Spitter; /** * ...
- SPRING IN ACTION 第4版笔记-第五章BUILDING SPRING WEB APPLICATIONS-004-以query parameters的形式给action传参数(@RequestParam、defaultValue)
一. 1.Spring MVC provides several ways that a client can pass data into a controller’s handler method ...
- SPRING IN ACTION 第4版笔记-第七章Advanced Spring MVC-005- 异常处理@ResponseStatus、@ExceptionHandler、@ControllerAdvice
No matter what happens, good or bad, the outcome of a servlet request is a servlet response. If an e ...
- SPRING IN ACTION 第4版笔记-第七章Advanced Spring MVC-003- 上传文件multipart,配置StandardServletMultipartResolver、CommonsMultipartResolver
一.什么是multipart The Spittr application calls for file uploads in two places. When a new user register ...
- SPRING IN ACTION 第4版笔记-第七章Advanced Spring MVC-002- 在xml中引用Java配置文件,声明DispatcherServlet、ContextLoaderListener
一.所有声明都用xml 1. <?xml version="1.0" encoding="UTF-8"?> <web-app version= ...
随机推荐
- typings的理解
简介一些js库扩展了JavaScript的特性和语法,但是TypeScript编译器并不识别,通过typings.json配置可以辅助IDE,给出有智能的提示信息,以及重构的依据.因此需要在typin ...
- svn版本控制器在vs2013中的使用
下面记录常用的几种用法: a) SVN检出 将SVN服务端所保存的数据下载到个人工作平台. 组长上传初始项目后,各组员可以到服务器上检出项目 1. 打开Visual Studio 2010-& ...
- nodejs笔记一--模块,全局process对象;
一.os模块可提供操作系统的一些基本信息,它的一些常用方法如下: var os = require("os"); var result = os.platform(); //查看操 ...
- Liferay JSP中常用的标签
(本文转载自http://www.cnblogs.com/edwardlauxh/archive/2010/03/26/1918614.html) 在Liferay框架中拥有它自身的标签,虽然Port ...
- CSS3图片旋转特效
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...
- WordPress按钮秒支付插件发布,支持微信支付,支付宝,银联,京东,苏宁,易宝支付
痛点: 我们用WordPress建设网站和开发移动应用,有时候我们其实不需要太多的流程,只是需要一个收款通道,但是可能对支持的渠道更加关注,特别是手机应用.所以WordPress按钮秒支付插件诞生了, ...
- Django RequestContext用法
模版中的变量由context中的值来替换,如果在多个页面模版中含有相同的变量,比如:每个页面都需要{{user}},笨办法就是在每个页面的请求视图中都把user放到context中. from d ...
- 老陈 WPF
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...
- Posix线程编程指南(5) 杂项
在Posix线程规范中还有几个辅助函数难以归类,暂且称其为杂项函数,主要包括pthread_self().pthread_equal()和pthread_once()三个,另外还有一个LinuxThr ...
- eclipse编辑jsp文件和javascript代码很卡解决办法
1.Window -> Preference -> General -> Editors -> Text Editors -> HyperLinking -> 在用 ...